Advertisement
Arsylk

Narkoman Industries

Mar 19th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. int decToSystem(int x, int base, int output[]) {
  8.     int i = 0;
  9.     for(i = 0; x > 0; i++) {
  10.         output[i] = x % base;
  11.         x /= base;
  12.     }
  13.     return i;
  14. }
  15.  
  16.  
  17.  
  18. int systemToDec(string x, int base) {
  19.     int ph = 0;
  20.     for(int i = 0; i < x.length(); i++) {
  21.         int conv = (x.at(i) - '0');
  22.         if(conv > 9) {
  23.             conv -= 7;
  24.         }
  25.         ph += conv * pow(base, x.length()-i-1);
  26.     }
  27.     return ph;
  28. }
  29.  
  30. int main() {
  31.     int bits[1000];
  32.     cout << systemToDec("FFFF", 16);
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement