#include <iostream>
#include <string>
using namespace std;
using std::string;
const string hexdigits = "0123456789ABCDEF"; // possible hex digits
int main()
{
cout << "Enter a series of numbers between 0 and 15"
<< " separated by spaces. Hit ENTER when finished: "
<< endl;
string result = ""; // will hold the resulting hexify’d string
unsigned int n; // hold numbers from the input
while (cin >> n )
{
if (n < 16) // ignore invalid input
result += hexdigits[n]; // fetch the indicated hex digit
else if (n == 17)
break;
}
cout << "Your hex number is: " << result << endl;
return 0;
}