这是一道小数把十进制转二进制的题 运行有问题 大家帮我看看有什么问题
#include<stdio.h>
#include<stdlib.h>
#define MAXLEN 100
typedef struct
{
int q[MAXLEN];
int front;
int rear;
}sqtype;
void initqueue(sqtype *sq)
{
sq->front=-1;
sq->rear=-1;
}
int empty(sqtype *sq)
{
if(sq->front==sq->rear)return 1;
return 0;
}
int full(sqtype *sq)
{
if(sq->front==(sq->rear+1)%MAXLEN)return 1;
return 0;
}
void addqueue(sqtype *sq,int x)
{
if(full(sq)==1)
{
printf("full");
return;
}
sq->rear=(sq->rear+1)%MAXLEN;
sq->q[sq->rear]=x;
}
int delqueue(sqtype *sq)
{
int x;
if(empty(sq)==1)
{
printf("empty");
return 0;
}
sq->front=(sq->front+1)%MAXLEN;
x=sq->q[sq->front];
return x;
}
void main()
{
sqtype *sq;
sq=(sqtype *)malloc(sizeof(sqtype));
float x=;
int y=0,n=0;
scanf("%d",&x);
initqueue(sq);
while(x!=0)
{
x=x*2;
if(x>=1)
{
y=1;
x=x-1;
}
else y=0;
addqueue(sq,y);
}
while(empty(sq)!=1)
{
n=delqueue(sq);
printf("%f",n);
}
printf("\n");
}