#includeusing namespace std; void convert(int n,int base,char a[]){ int i=0; while(n>0){ if(base<10||n%base<10){ a[i++]=n%base+'0';//填空 } else{ a[i++]=n%base+'A'-10;//填空 } n=n/base; } a[i]=' '; } void print(char a[]){ int i=0,j=0,temp=0; while(a[j])j++; j=j-1;//填空 for(;i >number>>base; convert(number,base,a);//填空 print(a); return 0; }
运行结果
123 2 结果:1111011 -------------------------------- Process exited after 3.178 seconds with return value 0 请按任意键继续. . .
123 16 结果:7B -------------------------------- Process exited after 3.909 seconds with return value 0 请按任意键继续. . .



