Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- int ilosc, jestLiczba1, jestLiczba2, dlugosc1, dlugosc2, liczba1, liczba2;
- scanf("%d", &ilosc);
- char input[2][11];
- char wynik[64];
- while (ilosc > 0)
- {
- scanf("%s %s", input[1], input[2]);
- dlugosc1 = strlen(input[1]);
- dlugosc2 = strlen(input[2]);
- for (int x = 0; x < dlugosc1; x++)
- {
- if (isdigit(input[1][x]))
- {
- jestLiczba1 = 1;
- }
- else
- {
- jestLiczba1 = 0;
- }
- }
- for (int x = 0; x < dlugosc2; x++)
- {
- if (isdigit(input[2][x]))
- {
- jestLiczba2 = 1;
- }
- else
- {
- jestLiczba2 = 0;
- }
- }
- if (jestLiczba1 == 0 && jestLiczba2 == 0)
- {
- printf("%s\n", strcat(input[1], input[2]));
- }
- if (jestLiczba1 == 1 && jestLiczba2 == 0)
- {
- liczba1 = 0;
- for (int y = 0; y < dlugosc1; y++)
- {
- liczba1 = liczba1 * 10 + input[1][y] - 48;
- }
- printf("%c\n", input[2][liczba1-1]);
- }
- if (jestLiczba1 == 0 && jestLiczba2 == 1)
- {
- liczba2 = 0;
- for (int y = 0; y < dlugosc2; y++)
- {
- liczba2 = liczba2 * 10 + input[2][y] - 48;
- }
- printf("%c\n", input[1][liczba2-1]);
- }
- if (jestLiczba1 == 1 && jestLiczba2 == 1)
- {
- liczba1 = 0;
- for (int y = 0; y < dlugosc1; y++)
- {
- liczba1 = liczba1 * 10 + input[1][y] - 48;
- }
- liczba2 = 0;
- for (int y = 0; y < dlugosc2; y++)
- {
- liczba2 = liczba2 * 10 + input[2][y] - 48;
- }
- printf("%d\n", liczba1 + liczba2);
- }
- ilosc--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement