daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. unsigned talgat_pow (unsigned a, unsigned x);
  3. unsigned reverse (unsigned );
  4. int main (void)
  5. {
  6.     unsigned m, n;
  7.     scanf("%u %u", &m, &n);
  8.     while (n--)
  9.         m += reverse(m);
  10.     if (m == reverse(m))
  11.     {
  12.         printf("Yes\n");
  13.         printf("%u\n", m);
  14.     }
  15.     else
  16.         printf("No\n");
  17.     return 0;
  18. }
  19. unsigned reverse (unsigned num)
  20. {
  21.     unsigned rev_num = 0, len = 0, num1 = num;
  22.     while (num1)
  23.     {
  24.         len++;
  25.         num1 /= 10;
  26.     }
  27.     while (len--)
  28.     {
  29.         rev_num += (num % 10) * talgat_pow(10, len);
  30.         num /= 10;
  31.     }
  32.     return rev_num;
  33. }
  34. unsigned talgat_pow (unsigned a, unsigned x)
  35. {
  36.     unsigned num = 1;
  37.     while (x--)
  38.     {
  39.         num *= a;
  40.     }
  41.     return num;
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top