Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #define MAX 5
  4. #define MAX2 10
  5.  
  6. int main()
  7. {
  8.     char A[MAX][MAX];
  9.     char *B[MAX2] = { NULL };
  10.     int pom = 96;
  11.     char c;
  12.  
  13.     //Wypelnianie macierzy
  14.  
  15.     for (int i = 0; i < MAX; i++) {
  16.         for (int j = 0; j < MAX; j++) {
  17.             pom++;
  18.             if (pom == 113 || pom == 118) {
  19.                 pom++;
  20.             }
  21.             else if (pom == 123) {
  22.                 pom = NULL;
  23.             }
  24.  
  25.             A[j][i] = pom;
  26.         }
  27.     }
  28.     //Wypisanie macierzy
  29.  
  30.     for (int i = 0; i < MAX; i++)
  31.     {
  32.         for (int j = 0; j < MAX; j++)
  33.             printf("%c\t", A[i][j]);
  34.         putchar('\n');
  35.     }
  36.  
  37.     //Wczytywanie ciagu znakow
  38.  
  39.     int k = 0;
  40.     printf("Podaj ciag znakow (max. %d):", MAX2);
  41.     do
  42.     {
  43.         c = getchar();
  44.  
  45.         for (int i = 0; i < MAX; i++)
  46.             for (int j = 0; j < MAX; j++)
  47.                 if (c == A[i][j])
  48.                 {
  49.                     B[k] = &A[i][j];
  50.                     printf("%d\n", B[k]);
  51.                     k++;
  52.                 }
  53.     } while (c != '\n');
  54.  
  55.     for (int i = 0; i < k; i++)
  56.         printf("%c", *B[i]);
  57.     putchar('\n');
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement