Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define MAXNAME 31
- #define MAXPEOPLE 80
- typedef struct human {
- char name[MAXNAME];
- int age;
- float weight;
- }individual;
- int main() {
- int i,currentsSize = 0,control = 0, teenager[MAXPEOPLE];
- struct human personVector[MAXPEOPLE];
- while(1) {
- printf("Entre com o nome do individuo : (tecle 'sair' para parar a insercao)\n");
- fflush(stdin);
- gets(personVector[currentsSize].name);
- if (strcmp(personVector[currentsSize].name,"sair") == 0){
- currentsSize--;
- break;
- }
- else {
- printf("Entre com o peso do individuo :\n");
- scanf("%f",&personVector[currentsSize].weight);
- printf("Entre com a idade do individuo :\n");
- scanf("%d",&personVector[currentsSize].age);
- if (personVector[currentsSize].age >= 12 && personVector[currentsSize].age <= 17) {
- teenager[control] = currentsSize;
- control++;
- }
- currentsSize++;
- }
- }
- printf("Pessoas com idades entre 12 e 17 anos :\n");
- for (i = 0; i < control; i++)
- {
- printf("%s\n",personVector[teenager[i]].name);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment