Advertisement
Guest User

kod

a guest
Dec 8th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.00 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.     int ilosc, jestLiczba1, jestLiczba2, dlugosc1, dlugosc2, liczba1, liczba2;
  7.     scanf("%d", &ilosc);
  8.     char input[2][11];
  9.     char wynik[64];
  10.  
  11.     while (ilosc > 0)
  12.     {
  13.         scanf("%s %s", input[1], input[2]);
  14.  
  15.         dlugosc1 = strlen(input[1]);
  16.         dlugosc2 = strlen(input[2]);
  17.  
  18.         for (int x = 0; x < dlugosc1; x++)
  19.         {
  20.             if (isdigit(input[1][x]))
  21.             {
  22.                 jestLiczba1 = 1;
  23.             }
  24.             else
  25.             {
  26.                 jestLiczba1 = 0;
  27.             }
  28.         }
  29.         for (int x = 0; x < dlugosc2; x++)
  30.         {
  31.             if (isdigit(input[2][x]))
  32.             {
  33.                 jestLiczba2 = 1;
  34.             }
  35.             else
  36.             {
  37.                 jestLiczba2 = 0;
  38.             }
  39.         }
  40.  
  41.         if (jestLiczba1 == 0 && jestLiczba2 == 0)
  42.         {
  43.             printf("%s\n", strcat(input[1], input[2]));
  44.         }
  45.         if (jestLiczba1 == 1 && jestLiczba2 == 0)
  46.         {
  47.             liczba1 = 0;
  48.             for (int y = 0; y < dlugosc1; y++)
  49.             {
  50.                 liczba1 = liczba1 * 10 + input[1][y] - 48;
  51.             }
  52.             printf("%c\n", input[2][liczba1-1]);
  53.         }
  54.         if (jestLiczba1 == 0 && jestLiczba2 == 1)
  55.         {
  56.             liczba2 = 0;
  57.             for (int y = 0; y < dlugosc2; y++)
  58.             {
  59.                 liczba2 = liczba2 * 10 + input[2][y] - 48;
  60.             }
  61.             printf("%c\n", input[1][liczba2-1]);
  62.         }
  63.         if (jestLiczba1 == 1 && jestLiczba2 == 1)
  64.         {
  65.             liczba1 = 0;
  66.             for (int y = 0; y < dlugosc1; y++)
  67.             {
  68.                 liczba1 = liczba1 * 10 + input[1][y] - 48;
  69.             }
  70.             liczba2 = 0;
  71.             for (int y = 0; y < dlugosc2; y++)
  72.             {
  73.                 liczba2 = liczba2 * 10 + input[2][y] - 48;
  74.             }
  75.             printf("%d\n", liczba1 + liczba2);
  76.         }
  77.  
  78.         ilosc--;
  79.     }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement