zoukankan      html  css  js  c++  java
  • 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 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
     
    Answer
    水题,从小到大排序。不舒服,水水更健康~
     
    #include <cstdio>
    #include <iostream>
    #include <sstream>
    #include <string>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #include <queue>
    #include <vector>
    #define PI acos(-1.0)
    #define ms(a) memset(a,0,sizeof(a))
    #define msp memset(mp,0,sizeof(mp))
    #define msv memset(vis,0,sizeof(vis))
    #define msd memset(dp,0,sizeof(dp))
    using namespace std;
    //#define LOCAL
    int main()
    {
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif // LOCAL
        ios::sync_with_stdio(false);
        int N;
        cin>>N;
        while(N--)
        {
            int n;
            cin>>n;
            vector<int> v;
            v.clear();
            for(int i=0;i<n;i++)
            {
                int t;
                cin>>t;
                v.push_back(t);
            }
            sort(v.begin(),v.end());
            printf("%d",v[0]);
            for(vector<int>::iterator it=v.begin()+1;it!=v.end();it++)
            {
                printf(" %d",*it);
            }
            printf("
    ");
        }
        return 0;
    }
    View Code
  • 相关阅读:
    android studio debug
    SharePoint 2013 单一页面赋设计权限
    sed实现文件自我复制
    iOS第三方支付集成
    移动端报表JS开发演示样例
    马化腾内部分享:产品经理的必修课
    实战c++中的string系列--string与char*、const char *的转换(data() or c_str())
    【React全家桶入门之十】登录与身份认证
    猜拳游戏案例
    Java JDBC利用反射技术将查询结果封装为对象
  • 原文地址:https://www.cnblogs.com/gpsx/p/5216269.html
Copyright © 2011-2022 走看看