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
  • 相关阅读:
    PostgreSQL 慢查询SQL语句跟踪
    unity WheelCollider调整
    C# 事件event
    C# 委托
    C4D导入fbx到Unity设置
    3DMAX导出fbx到unity设置
    unity 单面模型shader
    对数平均数
    GameObject:activeInHierarchy、activeSelf Behaviour:enabled
    unity Time.deltaTime
  • 原文地址:https://www.cnblogs.com/gpsx/p/5216269.html
Copyright © 2011-2022 走看看