这个哪里存在问题的?
#include<stdio.h>#define FALSE 0
#define TURE 1
longBinaryInput();
int isInputError( int binary);
long Binarytodecimal( int binary);
int main(void)
{
long binary,decimal;
while(1)
{
binary=BinaryInput();
if(isInputError(binary)==FALSE)
continue;
else
{
decimal=Binarytodecimal(binary);
break;
}
}
printf("二进制数%d对应的十进制数是:%d\n",binary,decimal);
return 0;
}
long BinaryInput()
{
int a;
printf("请输入一个二进制数:");
scanf("%d",&a);
return a;
}
int isInputError( int binary)
{
int b,t=1;
while (binary>0)
{
b=binary%10*t;
binary=binary/10;
t=t*2
}
if(binary)
return 0;
else
return 1;
}
long Binarytodecimal( int binary)
{
int sum=0,p=1;
while (binary)
{
int b;
b=binary%10;
sum=sum+b*p;
p=p*2;
binary=binary/10;
return sum;
}
}