Advertisement
jkonefal

Untitled

Nov 22nd, 2021
945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>a
  3.  
  4. void bin(int n, int k)
  5. {
  6.     int poz[32], i = 0, l, wynik=0, kopia;
  7.     kopia = n;
  8.     while (n > 0) {
  9.         poz[i] = n % k;
  10.         n = n / k;
  11.         i++;
  12.     }
  13.     l = i / 2;
  14.     for (int j = 0; j < l; j++)
  15.     {
  16.         if (poz[i-j-1] != poz[j])
  17.         {
  18.             wynik = 1;
  19.             break;
  20.         }
  21.     }
  22.     if (wynik == 0) printf("%d %s", kopia, "jest palindromem");
  23.     else printf("%d %s", kopia, "nie jest palindromem");
  24.  
  25. }
  26.  
  27. int main()
  28. {
  29.     int n, k ;
  30.     scanf("%d %d", &n, &k);
  31.     bin(n, k);
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement