#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;