zoukankan      html  css  js  c++  java
  • hdu 4176

    Class Statistics

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 233    Accepted Submission(s): 153


    Problem Description
    The new principal of Woop Woop Public plans to meet the teaching team to discuss the performance of the classes/teachers and, being a bean counting fundamentalist, he wants to arm himself with some statistics for the meetings.
    Your task is to write a program that reads the pupils' marks in each class and generates performance reports for the principal prior to the meetings.
     
    Input
    The input starts with an integer K (1 <= K <= 100) indicating the number of classes on a line by itself. Each of the following K lines gives a class's data, which starts with an integer N (2 <= N <= 50) indicating the number of pupils in the class. The number of pupils is followed by their marks, given as integers, in the range of zero to one hundred, separated by single spaces.
     
    Output
    The report for each class consists of two lines.
    The first line consists of the sentence: "Class X", where X indicates the class number starting with the value of one.
    The second line reports the maximum class mark, minimum class mark and the largest difference between consecutive marks (when sorted in non-decreasing order) in the class using the formats shown in the sample below.
     
    Sample Input
    2 5 30 25 76 23 78 6 25 50 70 99 70 90
     
    Sample Output
    Class 1 Max 78, Min 23, Largest gap 46 Class 2 Max 99, Min 25, Largest gap 25
     
    Source
     
    Recommend
    lcy   |   We have carefully selected several similar problems for you:  4178 4177 4179 4180 4181
     
    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    int a[500];
    int main(){
        int t;
        scanf("%d",&t);
        int cnt=0;
        while(t--){
            int n;
            cnt++;
            memset(a,0,sizeof(a));
            scanf("%d",&n);
            int temp=-1,temp1;
            for(int i=0;i<n;i++){
                scanf("%d",&a[i]);
    
    
                }
            sort(a,a+n);
            for(int i=1;i<n;i++){
    
                     temp1=a[i]-a[i-1];
                if(temp1>temp)
                    temp=temp1;
            }
            printf("Class %d
    ",cnt);
            printf("Max %d, Min %d, Largest gap %d
    ",a[n-1],a[0],temp);
    
        }
    
        return 0;
    }
  • 相关阅读:
    Hive表中四种不同数据导出方式以及如何自定义导出列分隔符
    build doris 0.11.5 on centos 7/ubuntu
    centos7 gcc升级
    linux-nohup后台运行
    sqoop import mysql to hive table:GC overhead limit exceeded
    Hive开启mapjoin优化、并行执行、动态分区
    How to Plan and Configure YARN and MapReduce 2 in HDP 2.0
    Android 8 AudioPolicy 初始化
    Android 8 声音调整过程
    qcom wlan kernel 解读 WCNSS_qcom_cfg.ini 文件
  • 原文地址:https://www.cnblogs.com/13224ACMer/p/4728953.html
Copyright © 2011-2022 走看看