2015
05-23

# Class Statistics

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.

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.

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.

2
5 30 25 76 23 78
6 25 50 70 99 70 90

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

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define maxn 1000
int a[maxn];
int main()
{
int i,j,t,n,ff=0;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
int maxx=0;
for(i=1;i<n;i++)
{
if(a[i]-a[i-1]>maxx)
maxx=a[i]-a[i-1];
}
printf("Class %d\n",++ff);
printf("Max %d, Min %d, Largest gap %d\n",a[n-1],a[0],maxx);
}
}