[1040]:As Easy As A+B(将输入的数排序)
2015-11-15 22:00
459 查看
As Easy As A+B
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 48533 Accepted Submission(s): 20781
Problem Description
These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fairly difficulty to do such a thing. Of course, I got it after many waking nights.
Give you some integers, your task is to sort these number ascending (升序).
You should know how easy the problem is now!
Good luck!
Input
Input contains multiple test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains an integer N (1<=N<=1000 the number of integers to be sorted) and then N integers follow in the same line.
It is guarantied that all integers are in the range of 32-int.
Output
For each case, print the sorting result, and one line one case.
Sample Input
2
3 2 1 3
9 1 4 7 2 5 8 3 6 9
Sample Output
1 2 3
1 2 3 4 5 6 7 8 9
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 48533 Accepted Submission(s): 20781
Problem Description
These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fairly difficulty to do such a thing. Of course, I got it after many waking nights.
Give you some integers, your task is to sort these number ascending (升序).
You should know how easy the problem is now!
Good luck!
Input
Input contains multiple test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains an integer N (1<=N<=1000 the number of integers to be sorted) and then N integers follow in the same line.
It is guarantied that all integers are in the range of 32-int.
Output
For each case, print the sorting result, and one line one case.
Sample Input
2
3 2 1 3
9 1 4 7 2 5 8 3 6 9
Sample Output
1 2 3
1 2 3 4 5 6 7 8 9
#include<stdio.h> int main() { int lines; while(scanf("%d", &lines)!=EOF){ int line; for(line=1; line<=lines; line++){ int count, i, str[1000], j, temp; scanf("%d", &count); for(i=0; i<count; i++){ scanf("%d", &str[i]); } for(j=0; j<(count-1); j++){ for(i=j+1; i<count; i++){ if(str[j]>str[i]){ temp = str[j]; str[j] = str[i]; str[i] = temp; } } } for(i=0; i<count; i++){ if(i==(count-1)){ printf("%d\n", str[i]); } else{ printf("%d ", str[i]); } } } } return 0; }
相关文章推荐
- Win7下完全卸载Oracle 11g的步骤
- 游戏区域系统设计
- Dex动态加载的C语言部分
- div与span的区别:
- 益西拉姆 20135239 +银雪纯 20125221 +马悦 20135235 实验1 实验报告
- Java中类与类、类与接口、接口与接口的关系
- HDOJ 5500 Reorder the Books(规律)
- JS知识点
- xcodebuild和xcrun的打包
- Asp.Net跨平台
- 感知机
- Python核心编程读笔 13:执行环境
- 20135306黄韧 ——第十章续
- 10 2048
- Swift(二十三、泛型)
- hdoj 3183 A Magic Lamp 【RMQ区间取数】
- Linux之uniq命令
- 游戏作弊器制作教程一:键盘鼠标模拟
- java5、java6、java7、java8的新特性
- 消失的死锁