A - Class Statistics

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   os   io   strong   

A - Class Statistics Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %lluSubmit Status Practice UVALive 5682

Description

 ///最開始 沒有讀懂  Largest gap坑也~~~    是拍好循序後的  連續最大差  #include <iostream> #include <string.h> #include <stdio.h> #include <algorithm> using namespace std; int main() {     int t;     int num;     int n;int a[150];     scanf("%d",&t);     for(num=1;num<=t;num++)     {         scanf("%d",&n);         for(int i=0;i<n;i++)         scanf("%d",&a[i]);         sort(a,a+n);         int sum=0;         for(int i=0;i<n-1;i++)         {             if(sum<(a[i+1]-a[i]))             sum=(a[i+1]-a[i]);         }         printf("Class %d\n",num);         printf("Max %d, Min %d, Largest gap %d\n",a[n-1],a[0],sum);     }     return 0; }

 

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 ( 1K100) 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 ( 2N50) 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

25 30 25 76 23 786 25 50 70 99 70 90

Sample Output

Class 1Max 78, Min 23, Largest gap 46Class 2Max 99, Min 25, Largest gap 25

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.