HDU 2019
来源:互联网 发布:网御数据库审计 编辑:程序博客网 时间:2024/04/28 17:02
数列有序!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 41048 Accepted Submission(s): 17774
Problem Description
有n(n<=100)个整数,已经按照从小到大顺序排列好,现在另外给一个整数x,请将该数插入到序列中,并使新的序列仍然有序。
Input
输入数据包含多个测试实例,每组数据由两行组成,第一行是n和m,第二行是已经有序的n个数的数列。n和m同时为0标示输入数据的结束,本行不做处理。
Output
对于每个测试实例,输出插入新的元素后的数列。
Sample Input
3 31 2 40 0
Sample Output
1 2 3 4#include<stdio.h>int main(){ int n,m,a[100],b[100],i,j,k,s,w,d; scanf("%d%d",&n,&m); while(!(n==0&&m==0)) { w=0; for(i=0;i<n;i++) scanf("%d",&a[i]); s=a[0]; if(m<s) { printf("%d",m); for(j=0;j<n;j++) { printf(" "); printf("%d",a[j]); } } else { for(j=0;j<n;j++) { if(m>a[j]) w=w+1; } for(j=0;j<w;j++) { printf("%d",a[j]); printf(" "); } printf("%d",m); for(j=w;j<n;j++) { printf(" "); printf("%d",a[j]); } } printf("\n"); scanf("%d%d",&n,&m); } return 0;}
0 0
- hdu 2019
- HDU 2019
- HDU-2019
- HDU 2019
- HDU 2019
- HDU 2019
- HDU--2019
- HDU 2019
- hdu 2019
- HDU-2019
- hdu 2019
- hdu 2019
- HDU 2019
- hdu 2019 排列有序
- HDU 2019 数列有序!
- hdu 2019 数列有序!
- hdu-2019-数列有序!
- hdu oj 2019
- 二十多岁的时候
- OpenSSL_add_all_digests 函数不是 thread-safe 的
- 【Java设计模式】装饰模式
- struts2.0中struts.xml配置文件详解
- GitLab安装过程及安装过程所遇问题解疑(安装过程参照光子CI之旅)
- HDU 2019
- 关闭Linux缓存
- libsvm工具包学习使用的一个好博客
- using namespace ns_xxx不能用在class定义内部
- ArcGIS for IOS 地图移动至某点或区域(个人)
- 2013年12月编程语言排行榜
- Windows7与Fedora 双系统下卸载Fedora Linux
- jsdoc3初次使用的遇到的一个错误:Error: Module jsdoc.js not found.
- 【分享】新浪微博个人微博数据集