HDU 1040


As Easy As A+B

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

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


#include<iostream>
#include<algorithm>
using namespace std;
int cmp(int a,int b)
{
return a<b;
}
int main()
{
int t,i,n;
int a[1005];
cin>>t;
while(t--)
{
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
sort(a,a+n,cmp);
for(i=0;i<n;i++)
//cout<<a[i]<<" ";
{
if(i<n-1)
cout<<a[i]<<" ";
if(i==n-1)
cout<<a[i];
}
cout<<endl;
}
return 0;
}

HDU 1040

时间: 2024-11-06 03:34:03

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) Total Submission(s): 53368    Accepted Submission(s): 22939 Problem Description These days, I am thinking about a question, how can I get a problem as

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

题意:给定n个数,让你从小到大排序. 析:不说什么了. 代码如下: #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const int maxn = 1000 + 5; int a[maxn]; int main(){ int T, n; cin >>

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 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 s

杭电 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) Total Submission(s): 43019    Accepted Submission(s): 18379 Problem Description These days, I am thinking about a question, how can I get a problem as

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

题意:裸排序 思路:排序 #include<iostream> #include<stdio.h> #include<algorithm> using namespace std; int a[1000]; int main(){ int t,n,i; scanf("%d",&t); while(t--){ scanf("%d",&n); for(i=0;i<n;++i) scanf("%d&quo

12月水题集锦

hdu 1040(本来想练个冒泡手速,竟然超时,果断sort....) <pre name="code" class="cpp">#include <stdio.h> #include<algorithm> using namespace std; int str[1000],n; #define forxunhuan for(int i=0;i<n;i++) int main(){ int t; scanf("%

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

基本思想: 在要排序的一组数中,对当前还未排好序的范围内的全部数,自上而下对相邻的两个数依次进行比较和调整,让较大的数往下沉,较小的往上冒.即:每当两相邻的数比较后发现它们的排序与排序要求相反时,就将它们互换. 算法实现:(HDU 1040 亲测 AC) #include<iostream> using namespace std; const int N =1005; void BubbleSort(int a[],int ); void print(int a[],int num); vo

ACM-简单题之As Easy As A+B——hdu1040

***************************************转载请注明出处:http://blog.csdn.net/lttree*************************************** As Easy As A+B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 35503    Accepte

(HDU)1040 --As Easy As A+B(像A+B一样简单)

题目链接:http://vjudge.net/problem/HDU-1040 思路:排序算法的水题.注意输出格式,数字之间有空格. 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 6 int main() 7 { 8 int n,num,i,j,temp; 9 int s[1010]; 10 scanf("%d",&