逆序存放问题
想实现数组a[10]逆序存放但输出还是a[i]
怎么回事呢???
main()
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
int n=strlen(a);
int i;
for(i=0;i<n/2;i++)
{
int ch;
ch=a[i];
a[i]=a[n-1];
a[n-1]=ch;
}
for(i=0;i<10;i++)
printf("%d",a[i]);
}
#include<stdio.h> int main(void) { int a[10]={0,1,2,3,4,5,6,7,8,9}; int n=9; int i,ch; for(i=0;i<n;i++,n--) { ch=a[i]; a[i]=a[n]; a[n]=ch; } for(i=0;i<10;i++) printf("%d",a[i]); getch(); }