将一个数组中的值按逆序重新存放.例如,原来顺序为8,6,5,4,1,要求改为1,4,5,6,的改错
#include<stdio.h>#defineN10intmain(void){inta[N],i,temp;printf("pleaseinput%dintegern...
#include<stdio.h>
#define N 10
int main(void)
{
int a[N], i, temp;
printf("please input %d integer numbers:\n", N);
for (i=0; i<N; i++)
{
scanf("%d", &a[i]);
}
printf("the array before reverse:\n");
for (i=0; i<N; i++)
{
printf("%d ", a[i]);
}
printf("\n");
/*********Found************/
for (i=0; i<N; i++)
{
temp = a[i];
/*********Found************/
a[i] = a[N-i];
/*********Found************/
a[N-i] = temp;
}
printf("the array after reverse:\n");
for (i=0; i<N; i++)
{
printf("%d ", a[i]);
}
printf("\n");
return 0;
}
在found下的第一行去找错误,我只找到一处,就找不到了,帮个忙,请大神们找找错误 展开
#define N 10
int main(void)
{
int a[N], i, temp;
printf("please input %d integer numbers:\n", N);
for (i=0; i<N; i++)
{
scanf("%d", &a[i]);
}
printf("the array before reverse:\n");
for (i=0; i<N; i++)
{
printf("%d ", a[i]);
}
printf("\n");
/*********Found************/
for (i=0; i<N; i++)
{
temp = a[i];
/*********Found************/
a[i] = a[N-i];
/*********Found************/
a[N-i] = temp;
}
printf("the array after reverse:\n");
for (i=0; i<N; i++)
{
printf("%d ", a[i]);
}
printf("\n");
return 0;
}
在found下的第一行去找错误,我只找到一处,就找不到了,帮个忙,请大神们找找错误 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |