Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>a
- void bin(int n, int k)
- {
- int poz[32], i = 0, l, wynik=0, kopia;
- kopia = n;
- while (n > 0) {
- poz[i] = n % k;
- n = n / k;
- i++;
- }
- l = i / 2;
- for (int j = 0; j < l; j++)
- {
- if (poz[i-j-1] != poz[j])
- {
- wynik = 1;
- break;
- }
- }
- if (wynik == 0) printf("%d %s", kopia, "jest palindromem");
- else printf("%d %s", kopia, "nie jest palindromem");
- }
- int main()
- {
- int n, k ;
- scanf("%d %d", &n, &k);
- bin(n, k);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement