Powered By Blogger

segunda-feira, 26 de janeiro de 2015

Matriz - contando vogais consoantes e espaços


Código desenvolvido pelo programador Samuel Lima:

#include<stdio.h>
#include<conio.h>
void Janela5(){system("Color F0");
int lin, col;
for ( lin = 0; lin <= 25; lin++ ){
for ( col = 0; col <= 80; col++ ){
gotoxy( col, lin );
if ( lin == 2 ){textbackground(LIGHTBLUE);printf( " ");}
if ( col == 1 ){textbackground(LIGHTBLUE);printf(" ");}
if ( lin == 25 ){textbackground(LIGHTBLUE);}
if ( col == 80 ){textbackground(LIGHTBLUE);printf(" ");}
}
}textbackground( BLACK );
}
void inicio( ){system ("title MATRIZ : CONTANDO VOGAIS CONSOANTES E ESPAÇOS");
int i;do{Janela5();textbackground(WHITE);
textcolor(LIGHTRED);gotoxy(21,7);printf("MATRIZ : CONTANDO VOGAIS CONSOANTES E ESPAÇOS");
textcolor(BROWN);gotoxy(25,10);printf("Programa desenvolvido por:");
textcolor(BLACK);gotoxy(52,10);printf("Samuel Lima");
textcolor(BLUE);gotoxy(34,12);printf("sa_sp10@hotmail.com");
textcolor(LIGHTBLUE);gotoxy(24,14);printf("DIGITE    PARA SAIR OU   PARA CONTINUAR  ");
textcolor(LIGHTRED);gotoxy(32,14);printf("1");textcolor(LIGHTRED);gotoxy(47,14);printf("2");
gotoxy(41,16);
scanf("%d",&i);fflush(stdin);
if( i == 1 ){textcolor(LIGHTRED);gotoxy(35,20);printf ("MUITO OBRIGADO");Sleep(1800);exit(0);}
if( i == 2 ){system("cls"); return;}
else {textcolor(LIGHTRED);gotoxy(37,20);printf ("\aOPÇÃO ERRADA");Sleep(1800);system("cls");}
}
while ( i );
}
int main(){
inicio();textbackground(WHITE);
char ch = 0;
int totvogmi = 0, totvogma = 0, totacet = 0,
totced = 0, totcon = 0, totcar = 0;
int j, w, x, y = 0, et = 0, ced = 0, ced01 = 0,
a = 0, e = 0, i = 0, o = 0, u = 0,
A = 0, E = 0, I = 0, O = 0, U = 0,
a0 = 0, a01 = 0, a02 = 0, a03 = 0,
e01 = 0, e02 = 0, i01 = 0,
o01 = 0, o02 = 0, o03 = 0,
u01 = 0, u02 = 0,
A0 = 0, A01 = 0, A02 = 0, A03 = 0,
E01 = 0, E02 = 0, I01 = 0,
O01 = 0, O02 = 0, O03 = 0,
U01 = 0, U02 = 0;
char Vet [ 16 ];
char matriz [ 11 ] [ 16 ] =
       {{"João Eugênio"    },
{"Átila Antônio"   },
{"Irene Patrícia"  },
{"Mônica Simões"   },
{"Ester Büeno"     },
{"Graça Núbia"     },
{"Fábio Júnior"    },
{"Ozéias Gonçalo"  },
{"Lúcia Píres"     },
{"Ulisses Ângelo"  },
{"Ítalo Guimarães" }};
system("cls");Janela5();textbackground(WHITE);
textcolor(LIGHTRED);gotoxy(20,3);printf("MATRIZ : CONTANDO VOGAIS CONSOANTES E ESPAÇOS");
textcolor(LIGHTRED);gotoxy(9,5);printf( "Nomes da Matriz" );
textcolor(LIGHTRED);gotoxy(36,5);printf( "Cada linha" );
textcolor(LIGHTRED);gotoxy(52,5);printf( "Conteúdo da Matriz" );
for (w = 0; w < 11; w++) {
gotoxy(5, w + 7);textcolor(BLACK);
for ( j = 0; j < 16; j++ ) {
printf(" %c", matriz [ w ] [ j ] );
Vet [ y ] =  matriz [ w ] [ j ];
y++;
}x = 11 * 16;
textcolor(LIGHTRED);printf("%d ", strlen ( matriz [ w ] ) );
textcolor(LIGHTBLUE);printf("letras");
totcar += strlen ( matriz [ w ] );
}
for ( y = 0; y < x; y++ ) {
ch = Vet [ y ];
if ( ch == 'a' )a++; if ( ch == 'e' )e++;   if ( ch == 'i' )i++;
if ( ch == 'o' )o++; if ( ch == 'u' )u++;   if ( ch == 'A' )A++;
if ( ch == 'E' )E++; if ( ch == 'I' )I++;   if ( ch == 'O' )O++;
if ( ch == 'U' )U++;
if ( ch == 'à' )a0++; if ( ch == 'á' )a01++;if ( ch == 'ã' )a02++;
if ( ch == 'â' )a03++;
if ( ch == 'é' )e01++;if ( ch == 'ê' )e02++;
if ( ch == 'í' )i01++;if ( ch == 'ó' )o01++;if ( ch == 'õ' )o02++;
if ( ch == 'ô' )o03++;if ( ch == 'ú' )u01++;if ( ch == 'ü' )u02++;
if ( ch == 'À' )A0++; if ( ch == 'Ã' )A01++;if ( ch == 'Á' )A02++;
if ( ch == 'Á' )A03++;
if ( ch == 'É' )E01++;if ( ch == 'Ê' )E02++;if ( ch == 'Í' )I01++;
if ( ch == 'Ó' )O01++;if ( ch == 'Õ' )O02++;if ( ch == 'Ô' )O03++;
if ( ch == 'Ú' )U01++;if ( ch == 'Ü' )U02++;
if ( ch == 'ç' )ced++;if ( ch == 'Ç' )ced01++;
if ( ch == ' ' )et++;
}
totvogmi = ( a + e + i + o + u );
totvogma = ( A + E + I + O + U );
totacet = ( a0 + a01 + a02 + a03 + e01 + e02 + i01 + o01 + o02 + o03 + u01 + u02 +
A0 + A01 + A02 + A03 + E01 + E02 + I01 + O01 + O02 + O03 + U01 + U02 );
totced = ( ced + ced01 );
totcon = totcar - ( totvogmi + totvogma + totacet + totced );
textcolor(BLACK);gotoxy(50,7);printf("vogais a minúsculo = ");
textcolor(LIGHTRED);printf("%d", a );
textcolor(BLACK);gotoxy(50,8);printf("vogais e minúsculo = ");
textcolor(LIGHTRED);printf("%d", e );
textcolor(BLACK);gotoxy(50,9);printf("vogais i minúsculo = ");
textcolor(LIGHTRED);printf("%d", i );
textcolor(BLACK);gotoxy(50,10);printf("vogais o minúsculo = ");
textcolor(LIGHTRED);printf("%d", o );
textcolor(BLACK);gotoxy(50,11);printf("vogais u minúsculo = ");
textcolor(LIGHTRED);printf("%d", u );
textcolor(BLACK);gotoxy(50,12);printf("vogais A maiúsculo = ");
textcolor(LIGHTRED);printf("%d", A );
textcolor(BLACK);gotoxy(50,13);printf("vogais E maiúsculo = ");
textcolor(LIGHTRED);printf("%d", E );
textcolor(BLACK);gotoxy(50,14);printf("vogais I maiúsculo = ");
textcolor(LIGHTRED);printf("%d", I );
textcolor(BLACK);gotoxy(50,15);printf("vogais O maiúsculo = ");
textcolor(LIGHTRED);printf("%d", O );
textcolor(BLACK);gotoxy(50,16);printf("vogais U maiúsculo = ");
textcolor(LIGHTRED);printf("%d", U );
textcolor(BLACK);gotoxy(50,17);printf("total de espaços   = ");
textcolor(LIGHTRED);printf("%d", et );
textcolor(BLACK);gotoxy(50,18);printf("Cedilhas minúscula = ");
textcolor(LIGHTRED);printf("%d", ced );
textcolor(BLACK);gotoxy(50,19);printf("Cedilhas maiúscula = ");
textcolor(LIGHTRED);printf("%d", ced01 );
textcolor(BLACK);gotoxy(5,19);printf("Todas consoantes   = ");
textcolor(LIGHTRED);printf("%d", totcon );
textcolor(BLACK);gotoxy(5,20);printf("vogais minúscula   = ");
textcolor(LIGHTRED);printf("%d", totvogmi );
textcolor(BLACK);gotoxy(5,21);printf("vogais maiúscula   = ");
textcolor(LIGHTRED);printf("%d", totvogma );
textcolor(BLACK);gotoxy(5,22);printf("Todos acentuados   = ");
textcolor(LIGHTRED);printf("%d", totacet );
textcolor(BLACK);gotoxy(5,23);printf("Todos as cedilhas  = ");
textcolor(LIGHTRED);printf("%d", totced );
textcolor(BLACK);gotoxy(50,21);printf("Todos Caracteres = ");
textcolor(LIGHTRED);printf("%d", totcar );
Sleep(1800);textcolor(LIGHTRED);gotoxy(50,23);
printf("MUITO OBRIGADO");
getche();
return(0);
}

Nenhum comentário:

Postar um comentário