nikolas_serafini

Lista 5 - Exercício 4

Jun 29th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.21 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int i,j = 0,characters[5] = {0}, totalcharacters = 0, totalvowels = 0, namevowels[5] = {0};
  6.    
  7.     char nomes[][30] = { "Jose Oliveira",
  8.                           "Joao Silverio",
  9.                           "Joana da Silva",
  10.                           "Mario da Silva Oliveira",
  11.                           "Pedro Oliveira de Souza"};
  12.  
  13.     for (i = 0; i < 5; i++)
  14.     {
  15.         while (nomes[i][j] != '\0')
  16.         {
  17.             if (nomes[i][j] != ' ')
  18.             {
  19.                characters[i]++;
  20.                totalcharacters++;
  21.             }
  22.            
  23.             if (nomes[i][j] == 'a' || nomes[i][j] == 'e' || nomes[i][j] == 'i' || nomes[i][j] == 'o' || nomes[i][j] == 'u' || nomes[i][j] == 'A' || nomes[i][j] == 'E' || nomes[i][j] == 'I' || nomes[i][j] == 'O' || nomes[i][j] == 'U')
  24.             {
  25.                 namevowels[i]++;
  26.                 totalvowels++;
  27.             }
  28.             j++;    
  29.         }
  30.         j = 0;
  31.     }
  32.  
  33.     for (i = 0; i < 5; i++)
  34.     {
  35.         printf("Nome %d : %d caracteres, %d vogais.\n",i+1,characters[i],namevowels[i]);
  36.     }
  37.     printf("Total de vogais = %d\nTotal de caracteres = %d\n",totalvowels,totalcharacters);
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment