标签:des style blog http color os io strong
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.
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
A - Class Statistics,布布扣,bubuko.com
标签:des style blog http color os io strong
原文地址:http://www.cnblogs.com/zhangying/p/3919976.html