zoukankan      html  css  js  c++  java
  • HDU 2561 二小整数

    第二小整数

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10966    Accepted Submission(s): 6710

    Problem Description
    求n个整数中倒数第二小的数。 每一个整数都独立看成一个数,比如,有三个数分别是1,1,3,那么,第二小的数就是1。
     
    Input
    输入包含多组测试数据。 输入的第一行是一个整数C,表示有C测试数据; 每组测试数据的第一行是一个整数n,表示本组测试数据有n个整数(2<=n<=10),接着一行是 n个整数 (每个数均小于100);
     
    Output
    请为每组测试数据输出第二小的整数,每组输出占一行。
     
    Sample Input
    2
    2
    1 2
    3
    1 1 3
     
    Sample Output
    2
    1
     
    Author
    yifenfei
     
    Source
     
    Recommend
    yifenfei
    排序输出第二小的数
    #include<iostream>
    #include<cstring>
    #include<queue>
    #include<cstdio>
    #include<algorithm>
    #include<cmath>
    using namespace std;
    #define maxn 1010
    #define INF 99999999
    int main()
    {
        int n;
        while(~scanf("%d",&n))
        {
            int t;
            while(n--)
            {
                int a[105];
                scanf("%d",&t);
                for(int i=0; i<t; i++)
                    scanf("%d",&a[i]);
                sort(a,a+t);
                printf("%d
    ",a[1]);
            }
    
        }
        return 0;
    }
    彼时当年少,莫负好时光。
  • 相关阅读:
    Java 代码中如何调用 第三方Api
    如何编写README.md
    Gof 设计模式
    系统架构师-笔记
    我的账户
    软件设计师-成绩查询
    spring data jpa
    日志 logback
    spring boot 整合 Camunda
    Spring 中 bean 的生命周期?
  • 原文地址:https://www.cnblogs.com/l609929321/p/6601406.html
Copyright © 2011-2022 走看看