Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<ctype.h>
- char words1[15][15]={'Y', 'C', 'Y', 'G', 'W', 'R', 'P', 'K', 'H', 'O', 'A', 'B', 'U', 'V', 'H', 'S', 'C', 'I', 'R', 'F', 'Z', 'B',
- 'M', 'C', 'P', 'M', 'Y', 'C', 'F', 'P', 'U', 'A', 'F', 'R', 'X', 'T', 'W', 'L', 'O', 'T', 'A', 'S', 'M', 'X',
- 'C', 'E', 'J', 'R', 'A', 'G', 'S', 'A', 'V', 'H', 'G', 'L', 'R', 'X', 'G', 'F', 'K', 'X', 'Z', 'T', 'A', 'P',
- 'C', 'V', 'J', 'Q', 'M', 'J', 'Y', 'M', 'G', 'G', 'C', 'X', 'Q', 'E', 'W', 'S', 'I', 'A', 'L', 'A', 'E', 'O',
- 'I', 'V', 'I', 'F', 'Y', 'F', 'X', 'V', 'A', 'L', 'P', 'A', 'L', 'H', 'E', 'T', 'A', 'L', 'E', 'K', 'O', 'U',
- 'U', 'T', 'I', 'G', 'U', 'A', 'N', 'C', 'O', 'I', 'V', 'H', 'I', 'H', 'Z', 'U', 'A', 'I', 'F', 'R', 'D', 'B',
- 'A', 'L', 'U', 'A', 'R', 'Z', 'H', 'X', 'C', 'L', 'C', 'O', 'G', 'E', 'E', 'X', 'V', 'R', 'U', 'N', 'B', 'S',
- 'T', 'M', 'U', 'S', 'I', 'C', 'A', 'T', 'L', 'A', 'A', 'W', 'R', 'A', 'U', 'J', 'A', 'B', 'I', 'S', 'S', 'N',
- 'O', 'R', 'I', 'S', 'C', 'M', 'P', 'L', 'E', 'N', 'P', 'A', 'L', 'C', 'O', 'A', 'H', 'B', 'E', 'T', 'M', 'F',
- 'O', 'T', 'Z', 'M', 'P', 'T', 'R', 'E', 'S', 'J', 'R', 'L', 'F', 'S', 'I', 'K', 'U', 'F', 'P', 'E', 'Q', 'T',
- 'A', 'M', 'L', 'O', 'J'};
- char words2[15][15];
- char words3[15][15];
- main()
- {
- char procura[15];
- int op,tam,let=0,cont=0,auxVer=0,auxHor=0;
- do{
- system("cls");
- for(int x=0;x<15;x++)
- {
- for(int y=0;y<15;y++)
- {
- words2[x][y] = '*';
- printf("%c ",words1[x][y]);
- }
- printf("\n");
- }
- printf("\nEntre com a palavra a ser procurada: ");
- gets(procura);
- tam=strlen(procura);
- for(int y=0; y<15; y++)
- {
- procura[y]=toupper(procura[y]);
- }
- for(int x=0;x<15;x++)
- {
- for(int y=0;y<15;y++)
- {
- if(y==0)
- let=0;
- if(procura[let]==words1[x][y])
- {
- auxHor=1;
- words2[x][y]=procura[let];
- let++;
- if(let==tam)
- {
- x=15;
- y=15;
- printf("Palavra encontrada\n\n");
- }
- }
- else
- {
- let=0;
- for(int c=0;c<15;c++)
- {
- for(int d=0;d<15;d++)
- words2[c][d] = '*';
- }
- }
- if(procura[cont]==words1[y][x])
- {
- words3[y][x]=procura[cont];
- cont++;
- if(cont==tam)
- {
- auxVer=1;
- x=15;
- y=15;
- printf("Palavra encontrada\n\n");
- }
- }
- else
- {
- cont=0;
- for(int a=0;a<15;a++)
- {
- for(int b=0;b<15;b++)
- {
- words3[a][b]='*';
- }
- }
- }
- }
- }
- if(auxHor==1)
- {
- for(int x=0;x<15;x++)
- {
- for(int y=0;y<15;y++)
- {
- printf("%c ", words2[x][y]);
- }
- printf("\n");
- }
- }
- if(auxVer==1)
- {
- for(int x=0;x<15;x++)
- {
- for(int y=0;y<15;y++)
- {
- printf("%c ", words3[y][x]);
- }
- printf("\n");
- }
- }
- system("pause");
- }while(op!=0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement