#include<iostream>#include<string>#include<algorithm>using namespace std;//将十进制data转换成N进制string TransToN(int data,int n){ string result=""; int index=0,i,j,temp[64]; if(data==0) { result="0"; } else { do { temp[index++]=data%n; data=data/n; } while(data!=0); for(--index;index>=0;index--) { if(temp[index]<10) result.append(1,temp[index]+'0'); else result.append(1,temp[index]+'A'-10); } } return result;}int main(){ int data,n=16; while(cin>>data) { string result=TransToN(data,n); cout<<result<<endl; } return 0;}
新闻热点
疑难解答