Advertisement
Hardware

Exercício 11 - Strings

Nov 16th, 2011
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. main()
  5. {
  6.       char txt[100],c[100],v[100];
  7.       int b,n,cv=0,cc=0;
  8.      
  9.       printf("Digite uma frase qualquer:");
  10.       gets(txt);
  11.      
  12.       for(b=0; txt[b] != '\0'; b++)
  13.       {
  14.            if((txt[b] == 'a') || (txt[b] == 'e') || (txt[b] == 'i') || (txt[b] == 'o') || (txt[b] == 'u'))
  15.            {
  16.                      v[cv] = txt[b];
  17.                      cv++;
  18.            }
  19.            else
  20.                if(txt[b] == ' ')
  21.                {
  22.                }
  23.                else
  24.                {
  25.                    c[cc] = txt[b];
  26.                    cc++;
  27.                }
  28.       }
  29.       v[cv] = '\0';
  30.       c[cc] = '\0';
  31.       system("CLS");
  32.       printf("Vetor original:");
  33.       puts(txt);
  34.       printf("Vetor Vogais:");
  35.       puts(v);
  36.       printf("Vetor Consoantes:");
  37.       puts(c);
  38.       system("Pause");
  39. }    
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement