数列有序!:
#include<iostream>
using namespace std;
#define N 1000
int a[N];
int main(){
int n,m;
while(cin>>n>>m&&n&&m){
int i;
for(i=1;i<=n;++i)
cin>>a[i];
for(i=n;i>=1;--i){
if(m<a[i])
a[i+1]=a[i];
else
break;
}
a[i+1]=m;
for(i=1;i<=n+1;++i){
cout<<a[i];
if(i<=n)
cout<<" ";
}
cout<<endl;
}
return 0;
}
转载于:https://blog.51cto.com/beyond316/1256084