Advertisement
Radostin05

Untitled

Nov 18th, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | Source Code | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int x;
  7.     cin>>x;
  8.     int y;
  9.     cin>>y;
  10.     if(x<2||x>16||y<1||y>100) {
  11.         cout<<"Invalid input data!"<<endl;
  12.         return 0;
  13.     }
  14.     const string digits="0123456789ABCDEF";
  15.     string result="";
  16.     while(y>0) {
  17.         result=digits[y%x]+ result;
  18.         y/=x;
  19.     }
  20.  
  21.     cout<<result;
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement