#define BITS 4 /** 定义的多少位数?*/
#define JIN 10 /**用于分解数据值的进制值。*/
/***
* 从标准输入得到输入数值
*/
int getBitsNum(){
int num = 0;
int bound_bottom = pow(JIN,BITS-1) - 1;
int bound_top = pow(JIN,BITS);
printf("请输入一个四位数 n ( %5d < n < %5d) : ",bound_bottom,bound_top);
scanf("%d",&num);
if(numbound_top)return 0;
else return num;
}
/** 打印数字数组用于测试观察!*/
void printBitArray(int *bitArray){
int i = 0;
for(i = 0; i < BITS; i++){
printf("%3d",*(bitArray+i));
}
putchar('\n');
}
/***
* 将数值按相应进制分解并将相应数字值保存到bitArray数组当中。
*/
void toBitArray(int num,int *bitArray){
//int bitArray[BITS] = {0};
int oringnal = num;