Guest User

Untitled

a guest
Feb 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     char arrA[5][5] = {'a', 'f', 'k', 'p', 'w',
  7.         'b', 'g', 'l', 'r', 'x',
  8.         'c', 'h', 'm', 's', 'y',
  9.         'd', 'i', 'n', 't', 'z',
  10.         'e', 'j', 'o', 'u', ' '};
  11.     char *arrB[100] = { NULL }; // tablica wskaznikow do arrA
  12.     char tekst[100]; //wczytywany tekst
  13.     int i, j, k;
  14.     printf("Podaj tekst majacy niewiecej niz 100 znakow.\nTekst: ");
  15.     fgets (tekst, 100, stdin);
  16.     for (k = 0; k < 100 ; k++)
  17.     {
  18.         for (i = 0; i < 5; i++)
  19.         {
  20.             for (j = 0; j < 5; j++)
  21.             {
  22.                 if(tekst[k] == arrA[i][j])
  23.                 {
  24.                     arrB[k] = &arrA[i][j];
  25.                 }
  26.             }
  27.         }
  28.         if(tekst[k] == '\n')
  29.             break;
  30.     }
  31.     printf("\n");
  32.     //wypisanie tekstu przez tablice wskaznikow arrB
  33.     for (i = 0; i < 101 && arrB[i] != '\0' ; i++)
  34.     {
  35.         printf("%c", arrB[i]);
  36.     }
  37.     printf("\nKoniec programu.\n");
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment