Advertisement
STANAANDREY

sb3 1 bac2020 t20

May 16th, 2022
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment
Advertisement