hdu 1040
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
Give you some integers, your task is to sort these number ascending (升序).
You should know how easy the problem is now!
Good luck!
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<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的更多相关文章
- 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 ...
- 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 ...
- HDU 1040 As Easy As A+B (排序。。。水题)
题意:给定n个数,让你从小到大排序. 析:不说什么了. 代码如下: #include <cstdio> #include <iostream> #include <cst ...
- hdu 1040 As Easy As A+B(排序)
题意:裸排序 思路:排序 #include<iostream> #include<stdio.h> #include<algorithm> using namesp ...
- HDU 1040 As Easy As A+B [补]
今天去老校区找她,不想带电脑了,所以没时间A题了 /*******************************************************************/ As Ea ...
- 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 ...
- HDU题解索引
HDU 1000 A + B Problem I/O HDU 1001 Sum Problem 数学 HDU 1002 A + B Problem II 高精度加法 HDU 1003 Maxsu ...
- 八大排序算法之六--交换排序—快速排序(Quick Sort)
基本思想: 1)选择一个基准元素,通常选择第一个元素或者最后一个元素, 2)通过一趟排序讲待排序的记录分割成独立的两部分,其中一部分记录的元素值均比基准元素值小.另一部分记录的 元素值比基准值大. 3 ...
- 八大排序算法之五--交换排序—冒泡排序(Bubble Sort)
基本思想: 在要排序的一组数中,对当前还未排好序的范围内的全部数,自上而下对相邻的两个数依次进行比较和调整,让较大的数往下沉,较小的往上冒.即:每当两相邻的数比较后发现它们的排序与排序要求相反时,就将 ...
随机推荐
- 28. extjs中Ext.BLANK_IMAGE_URL的作用
转自:https://blog.csdn.net/yiyuhanmeng/article/details/6960132 在使用ExtJS时,我们往往需要在使用之前加入这么一句:Ext.BLANK_I ...
- 炫酷的 CSS 形状(值得收藏)
在今日头条中看到炫酷的 CSS 形状,就记录一下: 1.圆形 #circle { width: 100px; height: 100px; background: red; border-radius ...
- Eclipse使用Tomcat发布项目时出现YadisException异常解决方案
调整使用Eclipse的JDK版本,大概JDK版本过低会出现这个org.openid4java.discovery.yadis.YadisException: 0x704: I/O transport ...
- 3-3 编程练习:jQuery键盘事件案例
3-3 编程练习 完善下面的代码,在input框中输入内容的时候同样显示在下面的p标签中 <!DOCTYPE html> <html lang="zh-CN"&g ...
- 题解报告:hdu 1010 Tempter of the Bone
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010 Problem Description The doggie found a bone in a ...
- sublime 3 最新注册码
http://9iphp.com/web/html/sublime-text-3-license-key.html
- CF817C Really Big Numbers
思路: 二分. 实现: #include <iostream> #include <cstdio> using namespace std; typedef long long ...
- cocos2d-x win7 部署
1. 安装 下载python https://www.python.org/downloads/release/python-279/ 2.从官网下载cocos2d-x http://www.co ...
- python 模块-easygui.buttonbox
2018-03-0315:43:11 ): Yes_or_No = easygui.buttonbox("是否良品?", choices=['Yes', 'No', '退出']) ...
- IDEA 提示Cannot resolve symbol
将Springboot项目,构建为多个模块的时候,idea的有些类中报错Cannot resolve symbol 解决: 1.File->Invalidate Caches/Restart 清 ...