Advertisement
weldisalves

2ª Prova(simulado) - Exercício 03

Jul 5th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.13 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4.    
  5. int main()
  6. {
  7.     char nome[100][30];
  8.     float dados[100][2],maisVelho=0,contMaisVelho=0;
  9.     int i,k,j;
  10.      
  11.     for(i=0;i<100;i++)
  12.     {
  13.     __fpurge(stdin);        
  14.     printf("\n Digite o nome: ");
  15.         fgets(nome[i],30,stdin);
  16.      
  17.         if(strlen(nome[i])==1) break;
  18.      
  19.         printf("\n Digite a idade: ");
  20.         scanf("%f",&dados[i][0]);//a posição j=0 é responsavel pelas idades
  21.      
  22.         printf("\n Digite o peso: ");
  23.         scanf("%f",&dados[i][1]);//a posição j=1 é responsavel pelos pesos
  24.      
  25.     if(dados[i][0]==maisVelho) contMaisVelho++;        
  26.    
  27.     if(dados[i][0]>maisVelho)
  28.         {
  29.             maisVelho = dados[i][0];
  30.             k=i;
  31.         }
  32.      
  33.      }
  34.              
  35.      for(j=0;j<i;j++)
  36.      {
  37.         if(dados[j][0]>=15 && dados[j][0]<=19 && dados[j][1]>80) printf("\n %s",nome[j]);
  38.      }
  39.      
  40.      if(contMaisVelho > 0)
  41.      {
  42.     printf("\n existe(m) outro(s)... nome: %s",nome[k]);
  43.      }else{
  44.         printf("\n Nome do mais velho: %s",nome[k]);
  45.           }
  46.         getchar();
  47.         return 0;
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement