The printed result of this binary number(x1,x2) is not what I want.(if I input :1234)Can anyone help me?
#include <stdio.h> int Count_one(int binary_number){ if(binary_number == 0) return 0; return Count_one(binary_number / 10) + binary_number % 10; } long long int HexadecimaltoDecimal(long long int hexadecimal_number, int power){ if(hexadecimal_number == 0) return 0; return HexadecimaltoDecimal(hexadecimal_number / 10, power * 16) + hexadecimal_number % 10 * power; } long long int DecimaltoBinary(long long int n, int power){ if(n == 0) return 0; return DecimaltoBinary(n / 2, power * 10) + n % 2 * power; } int main(){ int time, num, b1, b2; long long int X1, X2; scanf("%d", &time); for(int i = 0;i < time;i++){ scanf("%d",&num); X1 = DecimaltoBinary(num, 1); b1 = Count_one(X1); printf("X1=%lld\n",X1);//I added it myself X2 = DecimaltoBinary(HexadecimaltoDecimal(num, 1), 1); b2 = Count_one(X2); printf("X2=%lld\n", X1);//I added printf("%d %d\n", b1, b2); } return 0; }