当前位置:网站首页>Exercise 7-3 store the numbers in the array in reverse order (20 points)
Exercise 7-3 store the numbers in the array in reverse order (20 points)
2022-07-04 09:47:00 【skeet follower】
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 10
The code is as follows :
#include<stdio.h>
int main()
{
int n,i;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
printf("%d",a[n-1]);
for(i=n-2;i>=0;i--){
printf(" %d",a[i]);
}
return 0;
}
summary : Topics need attention , It requires that there should be no extra spaces at the end of the output line , So we should output the last element first , utilize for Loop to output other elements in turn .
边栏推荐
- mmclassification 标注文件生成
- The child container margin top acts on the parent container
- C # use ffmpeg for audio transcoding
- 2022-2028 global special starch industry research and trend analysis report
- Research Report on the development trend and Prospect of global and Chinese zinc antimonide market Ⓚ 2022 ~ 2027
- Global and Chinese market of sampler 2022-2028: Research Report on technology, participants, trends, market size and share
- How web pages interact with applets
- Global and Chinese markets of hemoglobin analyzers in care points 2022-2028: Research Report on technology, participants, trends, market size and share
- Global and Chinese market of planar waveguide optical splitter 2022-2028: Research Report on technology, participants, trends, market size and share
- 2022-2028 global optical transparency industry research and trend analysis report
猜你喜欢
2022-2028 global elastic strain sensor industry research and trend analysis report
PHP book borrowing management system, with complete functions, supports user foreground management and background management, and supports the latest version of PHP 7 x. Database mysql
How web pages interact with applets
Hands on deep learning (44) -- seq2seq principle and Implementation
Advanced technology management - how to design and follow up the performance of students at different levels
智能网关助力提高工业数据采集和利用
mmclassification 标注文件生成
Daughter love in lunch box
2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report
Machine learning -- neural network (IV): BP neural network
随机推荐
Hands on deep learning (40) -- short and long term memory network (LSTM)
Machine learning -- neural network (IV): BP neural network
C # use gdi+ to add text to the picture and make the text adaptive to the rectangular area
Hands on deep learning (38) -- realize RNN from scratch
MATLAB小技巧(25)竞争神经网络与SOM神经网络
Report on the development trend and prospect trend of high purity zinc antimonide market in the world and China Ⓕ 2022 ~ 2027
Qtreeview+ custom model implementation example
Leetcode (Sword finger offer) - 35 Replication of complex linked list
Hands on deep learning (37) -- cyclic neural network
7-17 crawling worms (15 points)
C language pointer interview question - the second bullet
el-table单选并隐藏全选框
Daughter love in lunch box
System. Currenttimemillis() and system Nanotime (), which is faster? Don't use it wrong!
2022-2028 global gasket plate heat exchanger industry research and trend analysis report
Ultimate bug finding method - two points
C language pointer classic interview question - the first bullet
2022-2028 global special starch industry research and trend analysis report
Implementing expired localstorage cache with lazy deletion and scheduled deletion
QTreeView+自定义Model实现示例