Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #define PEOPLE 100
- #define NAMESIZE 31
- int main()
- {
- int age[PEOPLE],i,flag = 0,oldestId = 0,total = 0;
- float weight[PEOPLE];
- char names[PEOPLE][NAMESIZE];
- while (1) {
- printf("Entre com o nome do usuario : (tecle apenas ENTER pra finalizar)\n");
- fflush(stdin);
- gets(names[total]);
- if (names[total][0] == '\0')
- break;
- printf("Entre com a idade:\n");
- scanf("%d",&age[total]);
- printf("Entre com o peso:\n");
- scanf("%f",&weight[total]);
- if (age[total] == age[oldestId] && total != i) {
- flag = 1;
- }
- else if (age[total] > age[oldestId]) {
- oldestId = total;
- flag = 0;
- }
- total++;
- }
- printf("Pessoas com idade entre 15 e 19 anos e peso superior a 80Kg :\n");
- for (i = 0; i < total; i++) {
- if (age[i] >= 15 && age[i] <= 19 && weight[i] > 80)
- puts(names[i]);
- }
- printf("Usuario mais velho :\n");
- if (flag == 1)
- printf("%s\nExiste(m) outro(s).\n",names[oldestId]);
- else
- puts(names[oldestId]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment