As Easy As A+B

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 70286    Accepted Submission(s): 29895

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
 
Author
lcy
思路:手写快排,
#include<cstdio>
#include<set>
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;
void quick_sort(int a[], int low, int high)
{
if (low >= high)return;
int s = low, e = high, key = a[low];
while (s < e){
while (s < e && a[e] >= key)e--;
a[s] = a[e];
while (s < e && a[s] <= key)s++;
a[e] = a[s];
}
a[s] = key;
quick_sort(a, low, s - );
quick_sort(a, s + , high);
}
int main()
{
int a[];
int t; cin >> t;
while (t--) {
int n; cin >> n; for (int i = ; i < n; i++)
cin >> a[i];
quick_sort(a, , n - );
for (int i = ; i < n; i++){
if (i == n - )cout << a[i] << endl;
else cout << a[i] << " ";
} }
return ;
}

hdu 1040的更多相关文章

  1. hdu 1040 As Easy As A+B

    As Easy As A+B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T ...

  2. HDU 1040 As Easy As A+B(排序)

    As Easy As A+B Problem Description These days, I am thinking about a question, how can I get a probl ...

  3. HDU 1040 As Easy As A+B (排序。。。水题)

    题意:给定n个数,让你从小到大排序. 析:不说什么了. 代码如下: #include <cstdio> #include <iostream> #include <cst ...

  4. hdu 1040 As Easy As A+B(排序)

    题意:裸排序 思路:排序 #include<iostream> #include<stdio.h> #include<algorithm> using namesp ...

  5. HDU 1040 As Easy As A+B [补]

    今天去老校区找她,不想带电脑了,所以没时间A题了 /*******************************************************************/ As Ea ...

  6. HDU 1040.As Easy As A+B【排序】【如题(水!水!水!)】【8月24】

    As Easy As A+B Problem Description These days, I am thinking about a question, how can I get a probl ...

  7. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

  8. 八大排序算法之六--交换排序—快速排序(Quick Sort)

    基本思想: 1)选择一个基准元素,通常选择第一个元素或者最后一个元素, 2)通过一趟排序讲待排序的记录分割成独立的两部分,其中一部分记录的元素值均比基准元素值小.另一部分记录的 元素值比基准值大. 3 ...

  9. 八大排序算法之五--交换排序—冒泡排序(Bubble Sort)

    基本思想: 在要排序的一组数中,对当前还未排好序的范围内的全部数,自上而下对相邻的两个数依次进行比较和调整,让较大的数往下沉,较小的往上冒.即:每当两相邻的数比较后发现它们的排序与排序要求相反时,就将 ...

随机推荐

  1. 【高德地图API】地理编码与逆地理编码

    一.地理编码 该功能实现地理编码服务,即地址匹配,从已知的地址描述到对应的经纬度坐标的转换,即根据地址信息,查询该地址所对应的点坐标等,地址(address) 为必选项,城市(city)为可选项. & ...

  2. [App Store Connect帮助]三、管理 App 和版本(7)移除 App

    若要在“我的 App”主视图中移除 App,要先将此 App 从 App Store 中移除,并将所有与之关联的 App 内购买项目下架. 此外,仅当 App 的所有版本均处于下列状态之一时方可移除: ...

  3. knockout jquery警告删除

    //触发删除的动作                $("a.delete").live('click', function () {                    var ...

  4. Qt实现客户端与服务器消息发送

    这里用Qt来简单设计实现一个场景,即: ①两端:服务器QtServer和客户端QtClient ②功能:服务端连接客户端,两者能够互相发送消息,传送文件,并且显示文件传送进度. 环境:VS20013+ ...

  5. C#命名空间 using的用法

    using的用法: 1. using指令:引入命名空间 这是最常见的用法,例如: using System; using Namespace1.SubNameSpace; 2. using stati ...

  6. 树形DP Gym 100496H House of Representatives

    题目传送门 /* 题意:寻找一个根节点,求min f(u) = ∑ρ(v, u) * p(v).ρ(v, u)是u到v的距离,p(v)是v点的权值 树形DP:先从1出发遍历第一次,sum[u]计算u到 ...

  7. Scala简单计算实例,其在数据分析方面的优势体会

    程序只是简单的从文件中读取数据,并进行计算. package com.bill.www /** * Created by Bill on 2016/2/3. * 目的:用scala实现简单的数据计算 ...

  8. 向listview控件中添加数据库数据

    //连接字符串 string str = "Data Source=.;Initial Catalog=mu;User ID=sa;Password=111"; //创建数据库连接 ...

  9. 人人都能读懂的css3 3d小demo

    css3 3d案例总结 最近入坑 Web 动画,所以把自己的学习过程记录一下分享给大家.就把最近做的比较好的给大家分享下 1.旋转拼图 首先看下效果 代码主要由HTML和CSS3组成,应该说还是比较简 ...

  10. 两年,VMware又重回巅峰?

    两年前,被公有云和容器打的焦头烂额的VMware一度被众多业界人士看衰,营收.股价双双下滑.然而,仅仅经过短短两年时间,VMware已经和AWS,IBM.微软.Rackspace等众多公有云厂商成为合 ...