#define N 10 main() { int a[N]={1,2,3,4,5,6,7,8,9,10} int i,j,t; printf("Before:

#define N 10
main()
{
int a[N]={1,2,3,4,5,6,7,8,9,10}
int i,j,t;
printf("Before:\n");
for(i=0;i<=N-1;i++)
printf("%4d",a[i]);
printf("\n");
for (i=0,j=N-1;i<j;i++,j--)
{ t=a[i];
a[i]=a[j];
a[j]=t;
}
printf("After:\n");
for(i=0;i<=N-1;i++)
printf("%4d",a[i]);
printf("\n");
}
请帮忙找一下错误吧!谢谢了!
最新回答
蓝雨希

2024-09-23 11:06:00

#include <stdio.h>
#define N 10
main()
{
int a[N]={1,2,3,4,5,6,7,8,9,10};
int i,j,t;
printf("Before:\n");
for(i=0;i<=N-1;i++)
printf("%4d",a[i]);
printf("\n");
for (i=0,j=N-1;i<j;i++,j--)
{ t=a[i];
a[i]=a[j];
a[j]=t;
}
printf("After:\n");
for(i=0;i<=N-1;i++)
printf("%4d",a[i]);
printf("\n");
}

加个头包含文件,以及在数组定义后面少‘;’号
锁骨草莓印

2024-09-23 11:45:15

int a[N]={1,2,3,4,5,6,7,8,9,10}
后面少个分号 这个是重要的 呵呵

用了printf,需要#include <stdio.h>吧
其他都正确!!