nikolas_serafini

Lista 6 - Exercício 6

Jul 16th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #define MAXSTU 5
  3. #define MAXNAME 40
  4.  
  5. struct Student {
  6.     char name[MAXNAME];
  7.     float med;
  8. };
  9.  
  10. int main() {
  11.  
  12.     int i, BiggerIndex;
  13.     float BiggerMed = 0;
  14.     struct Student StudentInfo[MAXSTU];
  15.  
  16.     for (i = 0; i < MAXSTU; i++) {
  17.         printf("Entre com o nome do estudante :\n");
  18.         fflush(stdin);
  19.         gets(StudentInfo[i].name);
  20.         printf("Entre com a media :\n");
  21.         scanf("%f",&StudentInfo[i].med);
  22.         if (StudentInfo[i].med > BiggerMed) {
  23.             BiggerMed = StudentInfo[i].med;
  24.             BiggerIndex = i;
  25.         }
  26.     }
  27.  
  28.     printf("Aluno com a media : %s\n",StudentInfo[BiggerIndex].name);
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment