hdoj 2019 数列有序!(水)

来源:互联网 发布:淘宝详情页面图片尺寸 编辑:程序博客网 时间:2024/05/04 06:51
http://acm.hdu.edu.cn/showproblem.php?pid=2019    

数列有序!

      一个sort函数从小到大排列。

代码:

 

#include<cstdio>#include<algorithm>using namespace std;int main(){   int n,m;   int a[110];   while(scanf("%d%d",&n,&m)&&(n||m))   {       for(int i=0;i<n;i++)       {           scanf("%d",&a[i]);       }       a[n]=m;       sort(a,a+n+1);       for(int i=0;i<n;i++)       {           printf("%d ",a[i]);        }        printf("%d\n",a[n]);    }    return 0;}


 

0 0
原创粉丝点击