第二次遇到这个题,不一定要用查找,也可以直接排序,sort真香
数列有序

#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int a[100],n,m;
	while(scanf("%d %d",&n,&m)!=EOF)
	{
		if(n==0&&m==0)break;
		for(int i=0;i<n;i++)
			scanf("%d",&a[i]);
			a[n]=m;
			sort(a,a+n+1);
		for(int j=0;j<n+1;j++)
		{
			if(j>0) printf(" ");
			printf("%d",a[j]);
		}
		printf("\n");
	}
	return 0;
}

相关文章:

  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-11
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-23
  • 2021-06-04
  • 2021-06-11
  • 2021-10-14
  • 2021-06-21
  • 2021-11-07
相关资源
相似解决方案