HDU排序水题
1040水题;
Give you some integers, your task is to sort these number ascending (升序).
You should know how easy the problem is now!
Good luck!
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.
3 2 1 3
9 1 4 7 2 5 8 3 6 9
1 2 3 4 5 6 7 8 9

#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排序水题的更多相关文章
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- PAT甲题题解-1012. The Best Rank (25)-排序水题
排序,水题因为最后如果一个学生最好的排名有一样的,输出的课程有个优先级A>C>M>E那么按这个优先级顺序进行排序每次排序前先求当前课程的排名然后再与目前最好的排名比较.更新 至于查询 ...
- PAT甲题题解-1062. Talent and Virtue (25)-排序水题
水题,分组排序即可. #include <iostream> #include <cstdio> #include <algorithm> #include < ...
- HDU 5391 水题。
E - 5 Time Limit:1500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- hdu 1544 水题
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...
- hdu 2710 水题
题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...
- hdu 5427(排序水题)
排序 年轻的排前面 名字中可能有空格 Sample Input21FancyCoder 19962FancyCoder 1996xyz111 1997 Sample OutputFancyCoderx ...
- hdu 5038 (2014北京网络赛G 排序水题)
题意:有n个数字,带入10000 - (100 - ai) ^ 2公式得到n个数,输出n个数中频率最大的数,如果有并列就按值从小到大都输出输出,如果频率相同的数字是全部的n个数,就输出Bad....题 ...
- Dijkstra算法---HDU 2544 水题(模板)
/* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...
随机推荐
- GridBagLayout布局管理器应用详解
http://www.cnblogs.com/kungfupanda/p/7220217.html GridBagLayout布局管理器应用详解 很多情况下,我们已经不需要通过编写代码来实现一个应用程 ...
- [Spark SQL_1] Spark SQL 配置
0. 说明 Spark SQL 的配置基于 Spark 集群搭建 && Hive 的安装&配置 1. 简介 Spark SQL 是构建在 Spark Core 模块之上的四大 ...
- laravel上传图片报错
在laravel的上传图片代码文件中路径如下: vendor\stevenyangecho\laravel-u-editor\src\Uploader\Upload.php第131行有一句代码错误$r ...
- 【CSS】Sass理解
原文在 https://github.com/zhongxia245/blog , 欢迎 star! Sass理解 时间:2016-09-24 22:56:12 作者:zhongxia 这里就不讲解S ...
- beta阶段学习博客(一) js交互
js交互 js交互的三种方法
- sqlserver 镜像 断开连接 正在恢复+主机服务器关机用备用镜像
如果主机坏了断开连接就用备机的镜像数据库 --主备互换,备机sql命令 USE master; ALTER DATABASE test SET PARTNER FORCE_SERVICE_ALLO ...
- 【转】Android 4.4中播放HTML5视频<video>的Bug
近期Nexus 4手机自动升级到Android4.4,本来挺好的一件事儿,结果发现自己的应用中出现一个Bug,应用中使用了Webview播放HTML5视频,代码如下: <video width= ...
- [转]VS2013+简单稀疏光束调整库SSBA配置(64位编译)
有关SSBA库的资源比较少,我是在Github上搜索下载的,具体的GitHub官方下载地址为:SSBA 下载后在SSBA解压文件夹下新建文件夹build. 打开cmake gui,在source co ...
- Python2.7-matplotlib
matplotlib的pyplot子库提供了和matlab类似的绘图API,方便用户快速绘制2D图表 一般用以下形式导入:import matplotlib.pyplot as plt 一般用法:1. ...
- 求 1+2+3+ …… +n
题目来源: 自我感觉难度/真实难度: 题意: 分析: 自己的代码: def Sum_Solution(n): # write code here if n==1: return 1 else: ans ...