#include <iostream>
using namespace std;
void decToBin(long x, char *a)
{
ltoa(x, a, 2);
}
void hexToDec(char *a, long &x)
{
x = strtol(a, (char**)NULL, 16);
}
int main()
{
long x;
char temp[255];
cout << "輸入一個十進制數: ";
cin >> x;
decToBin(x, temp);
cout << "轉換成二進制爲: " << temp << endl;
cout << "輸入一個十六進制數: ";
cin >> temp;
hexToDec(temp, x);
cout << "轉換爲十進制爲: " << x << endl;
return 0;
}