HDU 1040 As Easy As A+B
HDU 1040 As Easy As A+B
题意:T组数据
一组先给个N
后面给N个数
将这N个数从小到大排列
解题思路:
究极水题,直接sort解决
代码如下:
1 #include <bits/stdc++.h> 2 #define mem(a) memset(a,0,sizeof(a)) 3 #define mem1(a) memset(a,-1,sizeof(a)) 4 #define forn(i,n) for(int i=0;i<n;++i) 5 #define for1(i,n) for(int i=1;i<=n;++i) 6 #define IO std::ios::sync_with_stdio(false); std::cin.tie(0) 7 #define ll long long 8 #define LL long long 9 #define inf 0x3f3f3f3f 10 #define INF 0x3f3f3f3f3f3f3f3f 11 #define N 1000000 12 using namespace std; 13 const int maxn=1e3+50; 14 //ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;} 15 //ll lcm(ll a, ll b){return a * b / gcd(a, b);} 16 17 int num[maxn]; 18 19 int main() 20 { 21 int T,n,m; 22 scanf("%d",&T); 23 while(T--) 24 { 25 ll tmp,ans=1; 26 scanf("%d",&n); 27 forn(i,n) 28 { 29 scanf("%lld",&num[i]); 30 } 31 sort(num,num+n); 32 for(int i=0;i<n;++i) 33 { 34 if(i==0) 35 printf("%d",num[i]); 36 else 37 printf(" %d",num[i]); 38 } 39 printf("\n"); 40 } 41 return 0; 42 }