Răspuns :
Răspuns:
#include <iostream>
using namespace std;
long long k,n,i,r[101];
char c;
int main()
{
cin>>c;cin.get();cin>>n;
if(c=='h'){
k=0;
while(n!=0)
{
k++;
r[k]=n%16;
n=n/16;
}
for(i=k;i>=1;i--)
if(r[i]<10)
cout<<r[i];
else {
if(r[i]==10)cout<<'A';
if(r[i]==11)cout<<'B';
if(r[i]==12)cout<<'C';
if(r[i]==13)cout<<'D';
if(r[i]==14)cout<<'E';
if(r[i]==15)cout<<'F';
}
}else
if(c=='o'){
k=0;
while(n!=0)
{
k++;
r[k]=n%8;
n=n/8;
}
for(i=k;i>=1;i--)
if(r[i]<10)
cout<<r[i];
}
else
if(c=='b'){
k=0;
while(n!=0)
{
k++;
r[k]=n%2;
n=n/2;
}
for(i=k;i>=1;i--)
if(r[i]<10)
cout<<r[i];
}
}
Explicație: