这样写扩展性会更好,数组中的个数可以是任意的,只需修改arrSize 即可
#include
using namespace std;
int main()
{
unsigned int i = 0, j = 0, t = 0;
const unsigned int arrSize = 5;
int array[arrSize];
cout<<"enter the origil array:"<
{
cin >> array[i];
}
for (i = 0, j = 0; j < arrSize /2; ++i, ++j)
{
t = array[i];
array[i] = array[arrSize - 1 - j];
array[arrSize - 1 - j] = t;
}
cout<<"the opposite array:"<
cout<
return 0;
}
#include
using namespace std;
int main()
{
int a[5],b[5,]i,j=4,t;
cout<<"enter the origil array:"<
{
cin>>a[i];
b[j]=a[i];
j--;
}
cout<<"the opposite array:"<
cout< return 0;
}
#include
using namespace std;
int main()
{
int array[5],i;
cout<<"enter the origil array:"<
{
cin>>array[4-i];
}
cout<<"the opposite array:"<
cout<
}