ramontricolor12

LISTA 06 - Exercício 03

Jul 15th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.61 KB | None | 0 0
  1. /* CABEÇALHO
  2.    Arquivo: LISTA 06 - Exercicio 3.c
  3.    Objetivo: Construa uma estrutura agenda para armazenar alguns dados.
  4.    Autor(a): Ramon Borges
  5.  */
  6.  
  7. #include <stdio.h>
  8. #define MAX 50
  9. #define NUMPHONE 10
  10. struct contato
  11. {
  12.     char nomeEmpresa[30], pessoaRespons[40], telefones[NUMPHONE][12];
  13.     int contadorPHONE;
  14. };
  15.  
  16. int main()
  17. {
  18.     struct contato agenda[MAX];
  19.     int i, j, contCONTATOS;
  20.     for(i = 0; i < MAX; i++)
  21.     {
  22.         agenda[i].contadorPHONE = 0;
  23.         printf("\nInforme o nome da empresa (digite ENTER p/ sair): ");
  24.         gets(agenda[i].nomeEmpresa);
  25.         if(agenda[i].nomeEmpresa[1] == '\0')
  26.             break;
  27.         printf("\nInforme o nome do responsavel: ");
  28.         gets(agenda[i].pessoaRespons);
  29.  
  30.         for(j = 0; j < NUMPHONE; j++)
  31.         {
  32.             printf("\nInforme o %d telefone (digite ENTER p/ finalizar) \nEX: DDD98761234\n=>",j+1);
  33.             gets(agenda[i].telefones[j]);
  34.             if(agenda[i].telefones[j][1] == '\0')
  35.                 break;
  36.             agenda[i].contadorPHONE++; // conta o numero total de telefones por contato.
  37.         }
  38.     }
  39.     contCONTATOS = i; // conta o numero de contatos cadastrados.
  40.     //Exibir no console
  41.     printf("*******************  DADOS  *********************************\n");
  42.     for(i = 0; i < contCONTATOS; i++)
  43.     {
  44.         printf("%s\n", agenda[i].nomeEmpresa);
  45.         printf("%s\n", agenda[i].pessoaRespons);
  46.  
  47.         for(j = 0; j < agenda[i].contadorPHONE; j++)
  48.             printf("%s\n", agenda[i].telefones[j]);
  49.         printf("-------------------------------------\n");
  50.     }
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment