sábado, 29 de agosto de 2015

Frases - removendo vogais

Neste exemplo mostro como remover vogais em uma frase
facilmente, copie o código e cole na sua IDE favorita
e compile, é indicado a iniciantes em Linguagem C.

Veja abaixo imagens do programa em execução:






Veja abaixo o código do programa:

#include <stdio.h>
#include <conio.h>
void Janela5 ( ) {
     int lin, col;
     col = 0;
     system ( "Color 10" );
     for ( lin = 2; lin <= 24; lin++ )
         for ( col = 2; col <= 78; col++ ) {
              gotoxy ( col, lin );
              textbackground ( LIGHTCYAN );
              printf ( " " );
         }
}
int continuando ( ) {
     int nr;
     do {
         system ( "Color 90" );
         Janela5 ( );
         textcolor ( LIGHTRED );
         gotoxy ( 30, 3 );
         printf ( "FRASES - REMOVENDO VOGAIS " );
         textcolor ( BROWN );
         gotoxy ( 25, 7 );
         printf ( "Programa desenvolvido por:" );
         textcolor ( GREEN );
         gotoxy ( 52, 7 );
         printf ( "Samuel Lima" );
         textcolor ( BLACK );
         gotoxy ( 34, 9 );
         printf ( "sa_sp10@hotmail.com" );
         textcolor ( LIGHTBLUE );
         gotoxy ( 23, 11 );
         printf ( "Digite " );
         textcolor ( LIGHTRED );
         printf ( " 0 " );
         textcolor ( LIGHTBLUE );
         printf ( " para sair ou " );
         textcolor ( LIGHTRED );
         printf ( " 1 " );
         textcolor ( LIGHTBLUE );
         printf ( " para continuar " );
         textcolor ( LIGHTRED );
         gotoxy ( 24, 13 );
         scanf ( "%d", &nr );
         fflush ( stdin );
         if ( nr == 0 ) {
              textcolor ( LIGHTRED );
              gotoxy ( 36, 18 );
              printf ( "MUITO OBRIGADO" );
              getche ( );
              exit ( 0 );
         } else if ( nr == 1 ) {
              return 1;
         }
         textcolor ( BLACK );
         gotoxy ( 36, 16 );
         printf ( "\aopcão errada!" );
         getche ( );
     } while ( 1 );
     return 1;
}
int main ( ) {
     system ( "title FRASES - REMOVENDO VOGAIS" );
     continuando ( );
     system ( "cls" );
     Janela5 ( );
     unsigned int cont, i, j, lenv;
     char vog_ais [ ] = "aeiouAEIOU";
     lenv = strlen ( vog_ais );
     char str [ 255 ];
     textcolor ( LIGHTRED );
     gotoxy ( 30, 3 );
     printf ( "FRASES - REMOVENDO VOGAIS " );
     textcolor ( LIGHTBLUE );
     gotoxy ( 20, 5 );
     printf ( "Digite uma frase ==> " );
     textcolor ( BLACK );
     gets ( str );
     textcolor ( LIGHTBLUE );
     gotoxy ( 20, 7 );
     printf ( "Frase digitada ==> " );
     textcolor ( BLACK );
     printf ( " %s", str );
     cont = 0;
     for ( i = 0; i <= strlen ( str ); i++ )
         for ( j = 0; j <= strlen ( vog_ais ); j++ )
              if ( str [ i ] == vog_ais [ j ] && str [ i ] != 0 )
                   cont++;
     textcolor ( LIGHTBLUE );
     gotoxy ( 20, 9 );
     printf ( "No nome ==> " );
     textcolor ( BLACK );
     printf ( "%s ", str );
     textcolor ( LIGHTBLUE );
     gotoxy ( 20, 11 );
     printf ( "Foram encontrados " );
     textcolor ( LIGHTRED );
     printf ( " %d ", cont );
     textcolor ( LIGHTBLUE );
     printf ( " Vogais" );
     textcolor ( LIGHTBLUE );
     gotoxy ( 20, 13 );
     printf ( "Mostrando abaixo o Nome ==> " );
     textcolor ( BLACK );
     printf ( "%s", str );
     textcolor ( LIGHTBLUE );
     gotoxy ( 20, 15 );
     printf ( "Sem suas vogais ==> " );
     for ( i = 0; i < strlen ( str ); i++ ) {
         for ( j = 0; j < lenv; j++ )
              if ( str [ i ] == vog_ais [ j ] )
                   break;
         if ( j == lenv ) {
              textcolor ( BLACK );
              printf ( " %c", str [ i ] );
         }
     }
     Sleep ( 1000 );
     textcolor ( LIGHTRED );
     gotoxy ( 36, 23 );
     printf ( "MUITO OBRIGADO" );
     getche ( );
     return ( 0 );
}






Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.