是一题对数组进行倒序排序的题目
编译没错,组建为何过不了,用的软件是C++ 6.0 但Visual Studio 也报同样的错误
#include<stdio.h>
int main()
{
void inv(int arr[],int n);
int i = 0; //cricle vary
int arr[] = {3,7,9,11,0,6,7,5,4,2};
int num = 10; //elements Numbers;
printf("The Original Numbers:\n");
for(i = 0;i < num;i++)
{
printf("%d ",arr[i]);
}
printf("\n");
inv(arr,num);
printf("The arry has been inverted:\n");
for(i = 0;i < num;i++)
{
printf("%d ",arr[i]);
}
printf("\n");
return 0;
}
void inv(int * arr,int n)
{
int * i = arr;
int * j = arr+n-1;
for(;i <= arr+(n-1)/2;i++,j--)
{
int temp = * i;
* i = * j;
* j = temp;
}
return;
}
希望能帮忙分析下