1040水题;

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
 
Author
lcy
 
#include<iostream>
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<cstring>
#include <algorithm> using namespace std; #define MAX 1005 bool cmp(int a,int b)
{
return a < b;
}
int main()
{
int t = 0;
int n = 1;
int a[MAX];
cin >> t;
while(t--)
{
memset(a,0,sizeof(a));
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> a[i];
}
sort(a,a+n,cmp);
int temp = n-1;
for(int j = 0; j < n;j++)
{
if(temp--) cout << a[j] << " ";
else cout << a[j];
}
cout << endl;
}
return 0;
}

HDU排序水题的更多相关文章

  1. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  2. PAT甲题题解-1012. The Best Rank (25)-排序水题

    排序,水题因为最后如果一个学生最好的排名有一样的,输出的课程有个优先级A>C>M>E那么按这个优先级顺序进行排序每次排序前先求当前课程的排名然后再与目前最好的排名比较.更新 至于查询 ...

  3. PAT甲题题解-1062. Talent and Virtue (25)-排序水题

    水题,分组排序即可. #include <iostream> #include <cstdio> #include <algorithm> #include < ...

  4. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  5. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

  6. hdu 2710 水题

    题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...

  7. hdu 5427(排序水题)

    排序 年轻的排前面 名字中可能有空格 Sample Input21FancyCoder 19962FancyCoder 1996xyz111 1997 Sample OutputFancyCoderx ...

  8. hdu 5038 (2014北京网络赛G 排序水题)

    题意:有n个数字,带入10000 - (100 - ai) ^ 2公式得到n个数,输出n个数中频率最大的数,如果有并列就按值从小到大都输出输出,如果频率相同的数字是全部的n个数,就输出Bad....题 ...

  9. Dijkstra算法---HDU 2544 水题(模板)

    /* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...

随机推荐

  1. python的学习之路day3

    大纲 1.汉字编码 2.浅拷贝与深拷贝 3.函数 4.return 5.函数的基本参数 6.format 7.三元运算(三目运算) 8.python的内置函数 abs() all() any() bo ...

  2. 49_分析代理类的作用与原理及AOP概念

    生活中的代理 武汉人从武汉的代理商手中买联想电脑和直接跑到北京传智播客旁边来找联想总部买电脑,你觉得最终的主体业务目标有什么区别吗?基本上一样吧,都解决了核心问题,但是,一点区别都没有吗?从代理商那里 ...

  3. sed和awk学习整理

    Awk和Sed的基本使用 可以用大至相同的方式调用sed 和awk .命令行讲法是:command [options] script filename几乎和所有的unlx程序一样,sed和awk都可以 ...

  4. 使用C#删除一个字符串数组中的空字符串

    C#中要如何才能删除一个字符串数组中的空字符串呢?随着微软对C#不断发展和更新,C#中对于数组操作的方式也变得越来越多样化.以往要实现过滤数组中的空字符串,都是需要实行循环的方式来排除和过滤.C#3. ...

  5. Beta阶段第五次冲刺

    Beta阶段第五次冲刺 严格按照Git标准来,组员有上传Git的才有贡献分没有的为0 代码签入图 1.part1 -站立式会议照片 2.part2 -项目燃尽图 3.part3 -项目进展 1.正在进 ...

  6. Win10无法启动软件提示MSVCP110.dll丢失

    遇到这种问题,第一种方法可以选择去https://www.microsoft.com/zh-CN/download/details.aspx?id=30679 官网去下载 vc++ 2012 安装和自 ...

  7. 13.1SolrCloud集群使用手册之Collections API

    转载请出自出处:http://www.cnblogs.com/hd3013779515/ 1.创建collection name:指明collection名字 router.name:指定路由策略,默 ...

  8. 遇到 ORACLE 错误 1658

    在对oracle导入数据时,多次报以下错误: IMP-00003: 遇到 ORACLE 错误 1659ORA-01659: 无法分配超出 1 的 MINEXTENTS (在表空间 ZSTA_DATA_ ...

  9. 死磕nginx系列--nginx服务器做web服务器

    nginx 做静态服务器 HTML页面如下 <!DOCTYPE html> <html lang="en"> <head> <meta c ...

  10. 8.UDP协议

    传输层协议:TCP UDP TCP和UDP有什么区别? TCP是面向连接的 UDP是面向无连接.在互通之前,面向连接的协议会先建立连接,如TCP会三次握手.所谓的建立连接,是为了在客户端和服务端维护连 ...