33,311
社区成员
发帖
与我相关
我的任务
分享
//#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int a[10];
for (int i = 0; i < 10; i++)
a[i] = i;
cout << endl << "The original array is" << endl;
cout << "a[10] = " << "{ ";
for (int i = 0; i < 10; i++)
{
cout << a[i] << "\t";
}
cout << "}"<<endl;
int endvalue = a[9];
int i = 9;
while(i >= 1)
{
a[i] = a[i-1];
i--;
}
a[0] = endvalue;
cout << endl << "The new array is" << endl;
cout << "a[10] = " << "{ ";
for (int i = 0; i < 10; i++)
cout << a[i] << "\t";
cout << "}"<<endl;
cin.get();
return 0;
}
参考一下吧#include <iostream>
using namespace std;
int main()
{
int a[10];
for (int i = 0; i < 10; i++)
{
a[i] = i;
}
cout << endl << "The original array is" << endl;
cout << "a[10] = " << "{ ";
for (int i = 0; i < 10; i++)
{
cout << a[i] << "\t";
}
cout << "}";
int endvalue = a[9];
int i = 9;
while (i >= 1)//原来这里符号写反了
{
a[i] = a[i - 1];
i--;
}
a[0] = endvalue;
cout << endl << "The new array is" << endl;
cout << "a[10] = " << "{ ";
for (int i = 0; i < 10; i++)
{
cout << a[i] << "\t";
}
cout << "}";
cin.get();
return 0;
}