zoukankan      html  css  js  c++  java
  • 找出第3名学生的成绩

    题目出处:桂电oj,网址:http://onlinejudge.guet.edu.cn/guetoj/problem/1030.html

    Description

    计算机创新工程训练基地进行完招新开始后,想知道本次考试第3名学生的成绩是多少?
    如果最高分有好多个学生,则相同成绩的学生都算第一名;同理,如果第二高分的有多个学生,都算第二名。
    当然这是简单题,请你快速编一个程序找到第3名的成绩。

    Input

    输入:输入有一组,每组有2行,第一行是学生人数N(1<=N<1000),第二行有N个整数,分别表示每个学生的成绩(0到150)。

    Output

    输出:对于每组输入,输出只有一行,即第3名学生的成绩,如果找不到,则输出No such score !

    Sample Input

    10
    90 84 90 60 70 65 73 85 98 98

    5
    90 90 89 90 90


    Sample Output

    85

    No such score !

    //----------------------------------------------------------------------------------------

    #include <iostream>
    using namespace std;
    int judge(int b,int a[]);
    int c = 0;
    int main()
    {
        int score [150];
        int a;
        cin >> a;
        for (int i = 0; i < a; i++)
        {
            cin >> score[i];
        }
        if (judge(a,score) == 1)
        {
            cout << score[c];
        }
        else
        {
            cout << "No such score ! ";
        }
        return 0;
    }
    int judge(int b,int a[])
    {
        int n = 3;
        for (int i = 0; i < b; i++)
        {
            for (int j = b - 1; j > i; j--)
            {
                if (a[j] > a[j-1])
                {
                        int tmp = a[j];
                        a[j] = a [j-1];
                        a[j-1] = tmp;
                }
            }
        }
       for (int i = 0; i < b; i++)
        {
            if (a[i] != a[i+1])
            {
                n--;
            }
            if (n == 0)
            {
                c = i;
                return 1;
            }
        }
        return 0;
    }

  • 相关阅读:
    TFS应用层服务器获取F5用户的真实IP地址(高可用性)
    安装TFS(2015)工作组模式代理服务器(Agent)
    Team Foundation Server 15 功能初探
    TFS 2013 生成(构建)历史记录保持策略(Retention Policy)
    TFS代码变更和工作项关联,为系统变更提供完美的跟踪轨迹
    修改TFS客户端的工作区类型
    比较TFS与SVN,你必须知道的10点区别
    数据字典
    查看源码 类图结构图(Eclipse + Idea)
    Mybatis对应的java和数据库的数据类型
  • 原文地址:https://www.cnblogs.com/ediszhao/p/3481429.html
Copyright © 2011-2022 走看看