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. pycharm的放大和缩小字体的显示 和ubunt的截圖工具使用 ubuntu上安装qq微信等工具

    https://www.cnblogs.com/sui776265233/p/9322074.html#_label0 ubuntu: 截圖工具的使用 在ubuntu 10.04 的时候,还可以很方便 ...

  2. Win7 user profile cant logon

    1.local user:testlb1 1234@cat can login safe model 1.重新启动计算机开机时连续点击F8,选择进入安全模式.2.开始-在搜索栏中输入services. ...

  3. 人工智能——Singleton模式

    上次在状态模式中的设计有一个严重的问题,就是如下: voidCTroll::ChageState(CState* pNewState) {        deletem_pCurrentState; ...

  4. npm WARN unmet dependency问题的解决方法

    remove node_modules $ rm -rf node_modules/ run $ npm cache clean 详见这里: http://stackoverflow.com/ques ...

  5. 8、JVM--虚拟机字节码执行引擎

    8.1.概述 执行引擎是Java虚拟机最核心的组成部分之一.“虚拟机”是一个相对于“物理机”的概念,这两种机器都有代码执行能力,其区别是物理机的执行引擎是直接建立在处理器.硬件.指令集和操作系统层面上 ...

  6. browerify初步了解

    之前在写Signature Request Warnings & eth_sign学习的时候在里的signing examples时了解到browserify工具,可以通过这个例子学习如何使用 ...

  7. Jmeter性能测试-分布式压力测试

    作为一个测试行业的菜鸟,由于投身于一个小公司,包揽所有的测试.刚开始的功能测试到接口测试,稳定性测试,兼容性测试等,一般由于是小项目所以对于性能有所忽略,也没怎么涉及,公司接了个大项目,后期对于性能上 ...

  8. 【转】 python中 * 的用法

    转自:https://www.cnblogs.com/jony7/p/8035376.html 1.表示乘号 2.表示倍数,例如: def T(msg,time=1):    print((msg+' ...

  9. WorldWind源码剖析系列:二维点类Point2d和三维点类Point3d

    PluginSDK中的点主要有二维和三维两种类型,分别用来描述平面和立体点.其类图如下. 这两个类比较简单.其字段成员主要用来描述点对象在各坐标轴上的分量. 属性Length用来返回二维和三维点的距离 ...

  10. leetcode650—2 Keys Keyboard

    Initially on a notepad only one character 'A' is present. You can perform two operations on this not ...