在下面显示的代码中,我无法以相反的顺序打印数组。除了相反的部分,其余代码工作正常。我该如何解决这个问题?
#include <stdio.h>
int main()
{
int arr[10]={1,2,3,4,5,6,7,8,9,10};
int i;
printf("Enter the values into the array and see them in normal and reverse order\n");
printf("------------------------------------------------------------------------\n");
printf("Enter the number of elements into the array\n");
scanf("%d",&i);
printf("Input %d elmements into the array:\n",i);
for (i = 0; i < 10; i ++)
{
printf("elemenet - %d: ",i);
scanf("%d",&arr[i]);
}
printf("\nThe values stored into the array are:\n");
for (i = 0; i < 10; i ++)
{
printf("%3d",arr[i] );
}
printf("\nThe values stored into the array in reverse order are:\n");
for (i = 0; i > 10; i --) \*something wrong here*\
{
printf("%5d",arr[i] );
}
printf("\n\n");
}
尤其是代码中应用了数组反向的部分如下所示:
printf("\nThe values stored into the array in reverse order are:\n");
for (i = 0; i > 10; i --) \*something wrong here*\
{
printf("%5d",arr[i] );
}
我无法弄清楚如何扭转它。您的帮助将不胜感激。