SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     int number, sys, result, degree, i, j, degreex;
  5.     int resultabc;
  6.    
  7.     scanf("%d %d", &number, &sys);
  8.     degree = 0;
  9.     degreex = 1;
  10.     if ( number < 0 ) {
  11.         number *= -1;
  12.         printf("%c", 45);
  13.     }
  14.     for ( i = number; i > 0; i /= sys ) {
  15.         degree += 1;
  16.     }
  17.     degree -= 1;
  18.     for ( j = 1; j <= degree; j++ ) {
  19.         degreex *= sys;
  20.     }
  21.     for ( ; degreex > 0; degreex /= sys ) {
  22.         result = number / degreex;
  23.         number %= degreex;
  24.         if ( result > 9 ) {
  25.             resultabc = '7' + result;
  26.            
  27.             printf("%c", resultabc);
  28.         } else {
  29.             printf("%d", result);
  30.         }
  31.     }
  32.     printf("\n");
  33.     return 0;
  34. }
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