Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.87 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4. #include<ctype.h>
  5. 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',
  6.                     'M', 'C', 'P', 'M', 'Y', 'C', 'F', 'P', 'U', 'A', 'F', 'R', 'X', 'T', 'W', 'L', 'O', 'T', 'A', 'S', 'M', 'X',
  7.                     'C', 'E', 'J', 'R', 'A', 'G', 'S', 'A', 'V', 'H', 'G', 'L', 'R', 'X', 'G', 'F', 'K', 'X', 'Z', 'T', 'A', 'P',
  8.                     'C', 'V', 'J', 'Q', 'M', 'J', 'Y', 'M', 'G', 'G', 'C', 'X', 'Q', 'E', 'W', 'S', 'I', 'A', 'L', 'A', 'E', 'O',
  9.                     'I', 'V', 'I', 'F', 'Y', 'F', 'X', 'V', 'A', 'L', 'P', 'A', 'L', 'H', 'E', 'T', 'A', 'L', 'E', 'K', 'O', 'U',
  10.                     'U', 'T', 'I', 'G', 'U', 'A', 'N', 'C', 'O', 'I', 'V', 'H', 'I', 'H', 'Z', 'U', 'A', 'I', 'F', 'R', 'D', 'B',
  11.                     'A', 'L', 'U', 'A', 'R', 'Z', 'H', 'X', 'C', 'L', 'C', 'O', 'G', 'E', 'E', 'X', 'V', 'R', 'U', 'N', 'B', 'S',
  12.                     'T', 'M', 'U', 'S', 'I', 'C', 'A', 'T', 'L', 'A', 'A', 'W', 'R', 'A', 'U', 'J', 'A', 'B', 'I', 'S', 'S', 'N',
  13.                     'O', 'R', 'I', 'S', 'C', 'M', 'P', 'L', 'E', 'N', 'P', 'A', 'L', 'C', 'O', 'A', 'H', 'B', 'E', 'T', 'M', 'F',
  14.                     'O', 'T', 'Z', 'M', 'P', 'T', 'R', 'E', 'S', 'J', 'R', 'L', 'F', 'S', 'I', 'K', 'U', 'F', 'P', 'E', 'Q', 'T',
  15.                     'A', 'M', 'L', 'O', 'J'};
  16. char words2[15][15];
  17. char words3[15][15];
  18. main()
  19. {
  20.     char procura[15];
  21.     int op,tam,let=0,cont=0,auxVer=0,auxHor=0;
  22.     do{
  23.         system("cls");
  24.         for(int x=0;x<15;x++)
  25.         {
  26.             for(int y=0;y<15;y++)
  27.             {
  28.                 words2[x][y] = '*';
  29.                 printf("%c ",words1[x][y]);
  30.             }
  31.             printf("\n");
  32.         }
  33.        
  34.         printf("\nEntre com a palavra a ser procurada: ");
  35.         gets(procura);
  36.         tam=strlen(procura);
  37.         for(int y=0; y<15; y++)
  38.         {
  39.             procura[y]=toupper(procura[y]);
  40.         }
  41.         for(int x=0;x<15;x++)
  42.         {
  43.             for(int y=0;y<15;y++)
  44.             {
  45.                 if(y==0)
  46.                     let=0;
  47.                 if(procura[let]==words1[x][y])
  48.                 {
  49.                     auxHor=1;
  50.                     words2[x][y]=procura[let];
  51.                     let++;
  52.                     if(let==tam)
  53.                     {
  54.                         x=15;
  55.                         y=15;
  56.                         printf("Palavra encontrada\n\n");
  57.                     }
  58.                 }
  59.                 else
  60.                 {
  61.                     let=0;
  62.                     for(int c=0;c<15;c++)
  63.                     {
  64.                         for(int d=0;d<15;d++)
  65.                             words2[c][d] = '*';
  66.                     }
  67.                 }
  68.                 if(procura[cont]==words1[y][x])
  69.                 {
  70.                     words3[y][x]=procura[cont];
  71.                     cont++;
  72.                     if(cont==tam)
  73.                     {
  74.                         auxVer=1;
  75.                         x=15;
  76.                         y=15;
  77.                         printf("Palavra encontrada\n\n");
  78.                     }
  79.                 }
  80.                 else
  81.                 {
  82.                     cont=0;
  83.                     for(int a=0;a<15;a++)
  84.                     {
  85.                         for(int b=0;b<15;b++)
  86.                         {
  87.                             words3[a][b]='*';
  88.                         }
  89.                     }
  90.                 }
  91.             }
  92.         }
  93.         if(auxHor==1)
  94.         {
  95.             for(int x=0;x<15;x++)
  96.             {
  97.                 for(int y=0;y<15;y++)
  98.                 {
  99.                     printf("%c ", words2[x][y]);
  100.                 }
  101.                 printf("\n");
  102.             }
  103.         }
  104.         if(auxVer==1)
  105.         {
  106.             for(int x=0;x<15;x++)
  107.             {
  108.                 for(int y=0;y<15;y++)
  109.                 {
  110.                     printf("%c ", words3[y][x]);
  111.                 }
  112.                 printf("\n");
  113.             }
  114.         }
  115.         system("pause");
  116.     }while(op!=0);
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement