-
Notifications
You must be signed in to change notification settings - Fork 1
/
estagio.c
40 lines (33 loc) · 803 Bytes
/
estagio.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#define MAX_ALUNOS 1001
int main()
{
int i, indice_melhor, n;
int turma=1;
struct
{
int codigo, media;
} alunos[MAX_ALUNOS];
/* le numero de alunos da primeira turma */
scanf("%d", &n);
while (n > 0)
{
/* le dados dos alunos */
for (i = 0; i < n; i++)
scanf("%d %d", &alunos[i].codigo, &alunos[i].media);
/* procura aluno de maior media */
indice_melhor = 0;
for (i = 1; i < n; i++)
if (alunos[i].media > alunos[indice_melhor].media)
indice_melhor = i;
/* escreve resposta */
printf("Turma %d\n", turma++);
for (i = 0; i < n; i++)
if (alunos[i].media == alunos[indice_melhor].media)
printf ("%d ", alunos[i].codigo);
printf ("\n\n");
/* le numero de alunos da proxima turma */
scanf("%d", &n);
}
return 0;
}