Advertisement
Guest User

Untitled

a guest
Apr 14th, 2015
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.36 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.         int a;
  6.         int b;
  7.         scanf("%d %d", &a, &b);
  8.        
  9.         char results[a][1000];
  10.         double totalPoints = 0;
  11.         int maxPoints = 0;
  12.         int minPoints = -1;
  13.        
  14.         int i;
  15.         for (i = 0; i < a; i++)
  16.         {
  17.                 char buff[1000];
  18.                 int total = 0;
  19.                 int j;
  20.                
  21.                 scanf("%999s", buff);
  22.                
  23.                 for (j = 0; j < b; j++)
  24.                 {
  25.                         int pts;
  26.                         scanf("%d", &pts);
  27.                         total += pts;
  28.                 }
  29.                
  30.                 if (total > maxPoints)
  31.                 {
  32.                         maxPoints = total;
  33.                 }
  34.                
  35.                 if (minPoints == -1 || total < minPoints)
  36.                 {
  37.                         minPoints = total;
  38.                 }
  39.                
  40.                 totalPoints += total;
  41.                 sprintf(results[i], "%s %d", buff, total);
  42.         }
  43.        
  44.         printf("Average points: %.2f\n", totalPoints / a);
  45.         printf("Max points: %d\n", maxPoints);
  46.         printf("Min points: %d\n\n", minPoints);
  47.        
  48.         puts("Student results:");
  49.         for (i = 0; i < a; i++)
  50.         {
  51.                 puts(results[i]);
  52.         }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement