Sunday, May 1, 2016

UVA 10473 - Simple Base Conversion

#include<bits/stdc++.h>
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
#define newl cout<<"\n"
#define putcase cout<<"Case "<<++cse<<":";
using namespace std;
void DecToHex(char s[])
{
    int num;
    num=atoi(s);
    cout<<"0x";
    //cout<<hex<<num<<endl;
    printf("%X\n",num);
}
void HexToDec(char s[])
{
    int num;
    stringstream ss;
    ss<<hex<<s;
    ss>>num;
    //cout<<num<<endl;
    printf("%d\n",num);
}
int main()
{
    char s[33];
    while(cin>>s){
    if(s[0]=='-')
    break;
    else if(s[1]=='x')
        HexToDec(s);
    else
        DecToHex(s);
    }
    return 0;
}

1 comment:

  1. 1XBet
    Betting in India. 1xbet app It can be great to find the most popular brands, 토토 especially jancasino ones herzamanindir.com/ that offer betting on sports such as football, tennis,  Rating: 1/10 · casino-roll.com ‎Review by Riku VihreasaariWhere can I find 1xbet?Where can I find 1xbet betting?

    ReplyDelete