Guest User

Untitled

a guest
Dec 8th, 2019
94
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.     int k;
  7.     int rslt = 0;
  8.     char line[200];
  9.    
  10.     scanf("%d%s", &k, line);
  11.    
  12.     for (int i = (int) strlen(line) -1 ; i >= 0 ; i--)
  13.     {
  14.         if (line[i] - '0' >= 0 && line[i] - '0' <= 9)
  15.             rslt += (int) pow(k, (int) strlen(line) - i - 1) * (line[i]-'0');
  16.         else
  17.             rslt += (int) pow(k, (int) strlen(line) - i - 1) * (line[i]-'a' + 10);
  18.     }
  19.    
  20.     printf("%d", rslt);
  21.    
  22.     return 0;
  23. }
RAW Paste Data