fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.  
  5. int N, i, j, maior, apontador, turma = 0, cont;
  6.  
  7.  
  8. scanf ("%d", &N);
  9.  
  10. while (N != 0){
  11. int alunos[N][2];
  12. int maiorMedia[N];
  13. maior = 0;
  14. apontador = 0;
  15. cont = 0;
  16. turma++;
  17. for (i = 0; i < N; i++) {
  18. for (j = 0; j < 2; j++) {
  19. scanf ("%d", &alunos[ i ][ j ]);
  20. }
  21. if (alunos[i][1] > maior) {
  22. maior = alunos[i][1];
  23. }
  24. }
  25.  
  26. for (i = 0; i < N; i++) {
  27. if (alunos[i][1] >= maior) {
  28. maiorMedia[apontador] = alunos[i][0];
  29. apontador++;
  30. }
  31. }
  32. maiorMedia[apontador] = -1;
  33.  
  34.  
  35. scanf ("%d", &N);
  36. printf("Turma %d\n", turma);
  37. while (maiorMedia[cont] != -1) {
  38. printf("%d ", maiorMedia[cont]);
  39. cont++;
  40. }
  41. printf("\n\n");
  42.  
  43. }
  44.  
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0s 4288KB
stdin
3
1 85
2 91
3 73
5
12300 81
12601 99
15023 76
10111 99
212 99
6
1223 22
1457 21
1277 99
1222 99
36247 99
125 99
0
stdout
Turma 1
2 

Turma 2
12601 10111 212 

Turma 3
1277 1222 36247 125