#include<iostream> #include<string> using namespace std; int main() { const string hexdigits="0123456789ABCDEF"; cout<<"Enter a series of numbers between 0 and 15"<<" separates by spaces ,Hit ENTR when finished:"<<endl; string result; string::size_type n; while(cin>>n) { if(n<hexdigits.size()) result+=hexdigits[n]; cout<<"Yours hex number is:"<<result<<endl; } return 0; }
运行结果:
时间: 2024-09-30 18:09:55