#include<iostream> using namespace std; int main() { int i; cin>>dec>>i; //cin>>oct>>i; //cin>>hex>>i; void decimalToBinary(int n); cout<<"ASCII: "<<char(i)<<endl; cout<<"OCT: "<<oct<<i<<endl; cout<<"HEX: "<<hex<<i<<endl; cout<<"DEC: "<<dec<<i<<endl; cout<<"BIN: "; decimalToBinary(i); return 0; } void decimalToBinary(int n) { int a; a = n % 2; // 取余 n = n >> 1; //右移一位 相当于除以2 if(0 != n) { decimalToBinary(n); } cout<<a; }