Advertisement
STANAANDREY

sb3 1 bac2020 t20

May 16th, 2022
437
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int transformareBaza10(int b, int n) {
  4.     int r = 0, p = 1;;
  5.     while (n) {
  6.         r += n % 10 * p;
  7.         n /= 10;
  8.         p *= b;
  9.     }
  10.     return r;
  11. }
  12.  
  13. int main() {
  14.  
  15.     printf("%d", transformareBaza10(2, 10010));//18
  16.     return 0;
  17. }
  18.  
Advertisement
RAW Paste Data Copied
Advertisement