Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- string trans(int b,int n)
- {
- string s="";
- while(n!=0)
- { char l=(n%b)+'0'; int c=n%b;
- if(c==10)s='A'+s;
- else if(c==11)s='B'+s;
- else if(c==12)s='C'+s;
- else if(c==13)s='D'+s;
- else if(c==14)s='E'+s;
- else if(c==15)s='F'+s;
- else {s=l+s;}
- n=n/b;
- }
- return s;
- }
- int main()
- {
- int t;
- cin>>t; int b,n;
- for(int i=1;i<=t;i++)
- {
- cin>>b>>n;
- if(b>n)cout<<"Case "<<i<<": "<<trans(n,b)<<endl;
- else {cout<<"Case "<<i<<": "<<trans(b,n)<<endl;}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement