nikolas_serafini

Lista 5 - Exercício 13

Jul 6th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #define MAX 50
  3. #define maxwords 30
  4.  
  5. int main()
  6. {
  7.   int i,sum = 0,people,ages[MAX];
  8.   char names[MAX][maxwords];
  9.  
  10.   printf("Entre com a quantidade de pessoas :\n");
  11.   scanf("%d",&people);
  12.  
  13.   for (i = 0; i < people; i++) {
  14.     printf("Entre com o nome :\n");
  15.     fflush(stdin);
  16.     gets(names[i]);
  17.     printf("Entre com a idade :\n");
  18.     scanf("%d",&ages[i]);
  19.     sum = sum + ages[i];
  20.   }
  21.  
  22.   for (i = 0; i < people; i++)
  23.   {
  24.     if (ages[i] > (float)sum/(float)people)
  25.       printf("%s\n",names[i]);
  26.   }
  27.  
  28.   return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment