我改过的代码如下:
#include
#include
using namespace std;
int main()
{
int i,j,k,n,big,small,b,s;
cin >> n;
if (n <= 0)
{
cout<<"n is error"<return 1;
}
int *a = new int[n];
for ( i=0; icin >> a[i];
if ( i==0 )
big=small=a[i];
else if ( a[i]>big ) {
big=a[i];
b=i;
}
else if ( a[i] small=a[i];
s=i;
}
}
a[b]=small;
a[s]=big;
for ( k=0; kif ( (k+1)%10==0 )
cout << a[k] << endl;
else
cout << a[k] << " " ;
}
cout << endl;
system("pause");
}