Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int n, cont = 1;
  5.  
  6. bool read() {
  7.     scanf("%d", &n);
  8.     return n != 0;
  9. }
  10.  
  11. void process() {
  12.     int pos[n];
  13.     char nome[n][16];
  14.     int pts[13][n];
  15.     int max;
  16.     int min;
  17.     int total[n];
  18.  
  19.     for (int i = 0; i < n; i++) {
  20.         max = -1;
  21.         min = 1001;
  22.         scanf("%s", &nome[i]);
  23.         total[i] = 0;
  24.  
  25.          for (int j = 0; j < 12; j++) {
  26.             scanf("%d", &pts[j][i]);
  27.  
  28.             if (pts[j][i] > max)
  29.                 max = pts[j][i];
  30.             if (pts[j][i] < min)
  31.                 min = pts[j][i];
  32.  
  33.             total[i] += pts[j][i];
  34.         }
  35.         //total[i] = pts[0][i]+pts[1][i]+pts[2][i]+pts[3][i]+pts[4][i]+pts[5][i]+pts[6][i]+pts[7][i]+pts[8][i]+pts[9][i]+pts[10][i]+pts[11][i];
  36.         total[i] -= max;
  37.         total[i] -= min;
  38.  
  39.         for (int k = 0; k < i; k++) {
  40.             if (strcmp(nome[i], nome[k]) < 0) {
  41.                 int aux = total[i];
  42.                 total[i] = total[k];
  43.                 total[k] = aux;
  44.                 char temp[16]; strcpy(temp, nome[i]);
  45.                 strcpy(nome[i], nome[k]);
  46.                 strcpy(nome[k], temp);
  47.                 //lol = true;
  48.             }
  49.             if (total[i] > total[k]) {
  50.                 int aux = total[i];
  51.                 total[i] = total[k];
  52.                 total[k] = aux;
  53.                 char temp[16]; strcpy(temp, nome[i]);
  54.                 strcpy(nome[i], nome[k]);
  55.                 strcpy(nome[k], temp);
  56.             }
  57.         }
  58.  
  59.     }
  60.  
  61.     printf("Teste %d", cont);
  62.  
  63.    for (int i = 0; i < n; i++) {
  64.  
  65.             pos[0] = 1;
  66.  
  67.             if (total[i] == total[i-1]) {
  68.                 pos[i] = pos[i-1];
  69.             }
  70.             else
  71.                 pos[i] = i+1;
  72.  
  73.         printf("\n%d %d %s", pos[i], total[i], nome[i]);
  74.     }
  75.  
  76. }
  77.  
  78. int main() {
  79.     while(read()) {
  80.         process();
  81.         cont++;
  82.         printf("\n\n");
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement