解题思路:
1.具体问题具体分析,本题要求输入十个数,定义数组长度为10就行了。
2.注意数组下标是从零开始的,最后一个下标为9;
数组下标 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
插入前 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 |
插入后 | 0 | 9 | 8 | 7 | 5 | 4 | 3 | 2 | 1 | 0 |
注意事项:
注意定义数组长度的时候为10,而不是9.
参考代码:
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int a[10];
int i;
for(i=0;i<=9;i++){
scanf("%d",&a[i]);
}
for(i=9;i>=0;i--){
printf("%d ",a[i]);
}
return 0;
}
0.0分
1 人评分