zoukankan      html  css  js  c++  java
  • E

    Description

    “Point, point, life of student!” 
    This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course. 
    There are 5 problems in this final exam. And I will give you 100 points if you can solve all 5 problems; of course, it is fairly difficulty for many of you. If you can solve 4 problems, you can also get a high score 95 or 90 (you can get the former(前者) only when your rank is in the first half of all students who solve 4 problems). Analogically(以此类推), you can get 85、80、75、70、65、60. But you will not pass this exam if you solve nothing problem, and I will mark your score with 50. 
    Note, only 1 student will get the score 95 when 3 students have solved 4 problems. 
    I wish you all can pass the exam! 
    Come on! 

    Input

    Input contains multiple test cases. Each test case contains an integer N (1<=N<=100, the number of students) in a line first, and then N lines follow. Each line contains P (0<=P<=5 number of problems that have been solved) and T(consumed time). You can assume that all data are different when 0<p. 
    A test case starting with a negative integer terminates the input and this test case should not to be processed. 

    Output

    Output the scores of N students in N lines for each case, and there is a blank line after each case. 

    Sample Input

    4
    5 06:30:17
    4 07:31:27
    4 08:12:12
    4 05:23:13
    1
    5 06:30:17
    -1

    Sample Output

    100
    90
    90
    95
    
    100


    题意:本题就是让你根据学生完成作业的数目以及所花费的时间给学生打分,当完成5个题目是就是100分,四个题就是90分(这里面如果有学生排名在前百分之五十的话就是95分),以此类推,让你输出每一个学生的分数


    分析:本题涉及到排序问题,如果将所有时间化为同一个单位再进行排序的话就感觉比较麻烦,于是我在百度上找到了专门对字符串进行排序的函数,直接用结构体排序排序就会简单很多


    心得:又学到一个新知识点,感觉还是比较好理解的


    知识点:结构体排序




    #include <iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    struct node
    {
        int x;
        char s[10];
    }a[101];
    int main()
    {
        int n;
        while(scanf("%d",&n),n!=-1)
        {
          for(int i=0;i<n;i++)
                scanf("%d %s",&a[i].x,a[i].s);
             int t[5]={0};
                for(int i=4;i>0;i--)//做出相同题数的人的个数 
                {
                    for(int j=0;j<n;j++)
                    {
                        if(a[j].x==i) t[i]++;
                    }
                }
                for(int i=0;i<n;i++)
                {
                    if(a[i].x==5) printf("100
    ");
                    else if (a[i].x==0) printf("50
    ");
                    else
                    {
                        int k=0;
                        for(int j=0;j<n;j++)
                        {
                            if(a[j].x==a[i].x&&strcmp(a[j].s,a[i].s)<0)
    //头文件是string,实质就是a[j].s<a[i].s
                                k++;
                        }
                        if(k>=t[a[i].x]/2) 
    //相同题数用时短的人数> 做出相同题数的总人数一半 
                            printf("%d
    ",100-(5-a[i].x)*10);
                        else 
                        printf("%d
    ",100-(5-a[i].x)*10+5);
                    }
                }
           printf("
    ");
        }
        return 0;
    }
    

      




  • 相关阅读:
    Sybase:游标用法以及嵌套用法
    EasyUI:获取某个dategrid的所有行数据
    EasyUI:所有的图标
    Sybase:SAP IQ学习笔记
    Sybase:SybaseIQ的几个系统过程
    Sybase:解锁
    Python3:文件读写
    Android Studio 1.0.2 设置内存大小
    关于Android的margin(当前视图与周围视图的距离)和padding(当前视图与内部内容的距离)
    《Android Studio开发实战 从零基础到App上线》资源下载和内容勘误
  • 原文地址:https://www.cnblogs.com/lbyj/p/5761100.html
Copyright © 2011-2022 走看看