当前位置:网站首页>Store the numbers in the array in reverse order
Store the numbers in the array in reverse order
2022-06-22 08:10:00 【Study hard 867】
This question requires the preparation of procedures , Will be given n An integer is stored in the array , Put this... In the array n The number is stored in reverse order , Then output the elements in the array in order .
Input format :
Input gives a positive integer in the first line n(1≤n≤10). Second line input n It's an integer , Separate with spaces .
Output format :
Output this on one line n The processing result of an integer , Adjacent numbers are separated by a space , There must be no extra space at the end of the line .
sample input :
4
10 8 1 2
sample output :
2 1 8 10Code :
#include <stdio.h>
int main(){
int a[10],N,i,temp,n;
scanf("%d",&N);
for(i=0;i<N;i++){
scanf("%d",&a[i]);
}
if(N%2==0){
n=N/2;
for(i=0;i<n;i++){
temp=a[i];
a[i]=a[2*n-i-1];
a[2*n-i-1]=temp;
}
}
else {
n=(N-1)/2;
for(i=0;i<n;i++){
temp=a[i];
a[i]=a[2*n-i];
a[2*n-i]=temp;
}
}
for(i=0;i<N-1;i++)printf("%d ",a[i]);
printf("%d",a[i]);
}
边栏推荐
- MySQL master-slave replication
- [普通物理]波的能量与干涉
- . Net core technology stack website Collection
- Oracle execution plan analysis
- Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - identify the emergence of the new K line
- Qt 错误提示1: invalid use of incomplete type ‘***‘
- MySQL view
- Mt4/mql4 getting started to be proficient in EA tutorial lesson 7 - common functions of MQL language (VII) - index value taking function
- XMIND 2022 mind map active resources?
- Mystery of power bank
猜你喜欢

【Oracle 数据库】奶妈式教程 day12 字符函数
![[Oracle database] mammy tutorial day13 date function](/img/ca/90aaa682ec393b1531060377276ca6.png)
[Oracle database] mammy tutorial day13 date function

模电实验——实验一 晶体管共射极单管放大器

Mt4/mql4 getting started to mastering EA tutorial lesson 3 - common functions of MQL language (III) - common functions of K-line value taking

Use of keepalived high availability cluster

QT error prompt 1:invalid use of incomplete type '***‘

Model electricity experiment -- Experiment 2 JFET common source amplifier circuit

RAID technology

Example of QT qtableview

歪门邪道之解决首屏图片加载闪烁问题
随机推荐
RAID technology
How to handle root password forgetting in MySQL
Stored procedures and functions of MySQL
Oracle database pl/sql procedure body, cursor, stored procedure
.net core 技术栈 网站收集
swagger中的枚举、自定义类型和swaggerignore
[songhongkang MySQL database] [advanced chapter] [07] MySQL storage engine
Mt4-mql4 language EA automatic transaction programming introduction to proficiency
Microsoft Remote Desktop 10.7.6 official
计算水费问题
Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - identify the emergence of the new K line
What is distributed transaction
Interview shock 59: can there be multiple auto increment columns in a table?
MySQL query group by 1055 is the simplest and most convenient way to solve the problem perfectly
Example of QT qtableview
dom4j+xpath解析xml文件
2022年CIO面临的七大挑战及应对方法
矩阵运算
Submit values of various inputs of the form
Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - special identification of the K line on the chart