SHARE
TWEET

Untitled

a guest Dec 8th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     freopen("input.txt", "r", stdin);
  6.     freopen("output.txt", "w", stdout);
  7.    
  8.     int arr[300];
  9.     int b;
  10.     int n = 0;
  11.    
  12.     for (int i = 0; i < 30; i++)
  13.         arr[i] = -1;
  14.        
  15.     scanf("%d%d", &b, &n);
  16.    
  17.     if (n == 0)
  18.     {
  19.         printf("0");
  20.         return 0;
  21.     }
  22.    
  23.     int i = 299;
  24.    
  25.     while (n > 0)
  26.     {
  27.         arr[i] = n % b;
  28.         n /= b;
  29.         i--;
  30.     }
  31.    
  32.     for (int j = i + 1; j < 300; ++j)
  33.     {
  34.         if (arr[j] > 9)
  35.             printf("%c", (char) (arr[j] + 87));
  36.         else
  37.             printf("%d", arr[j]);
  38.     }
  39.    
  40.     return 0;
  41. }
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