#include "stdio.h"
void sort(int number[],int n,int m);
int main(){
int n,m,i,number[100];
scanf("%d%d",&n,&m);
while(n!=0 || m!=0){
for(i=0;i<n;i++){
scanf("%d",&number[i]);
}
sort(number,n,m);
for(i=0;i<=n;i++){
if(i!=n)
printf("%d ",number[i]);
else
printf("%d\n",number[i]);
}
scanf("%d%d",&n,&m);
}
return 0;
}
void sort(int number[],int n,int m){
int i,count;
for(i=0;i<n;i++){
if(m<=number[i])
break;
}
count=i;
for(i=n;i>count;i--)
number[i]=number[i-1];
number[count]=m;
}
时间: 2024-10-15 12:09:51