Mọi người giúp em với ạ, sao nó kết quả đổi cứ ra =0
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include <conio.h>
typedef struct{
int dl;
}Data;
/////////////////////////////////
typedef struct tagNode{
Data infor;
struct tagNode *link;
}Node;
/////////////////////////////////
typedef struct{
Node *pHead;
Node *pTail;
int spt;
}Queue;
/////////////////////////////////
//tao 1 hang doi rong
void init_Q(Queue&Q)
{
Q.pHead= NULL;
Q.pTail= NULL;
Q.spt=0;
}
//kiem tra hang doi co rong khong?
int empty_Q(Queue&Q)
{
return (Q.spt==0);
}
int full_Q(Queue Q)
{
return 0;
}
//them cuoi
void add_Q(Queue &Q, Data x)
{
Node *pp;
pp=(Node*)malloc(sizeof(Node));
pp->infor=x;
pp->link=NULL;
if(empty_Q(Q)){
Q.pTail=Q.pHead=pp;
}
else{
Q.pTail->link=pp;
Q.pTail=pp;
}
Q.spt++;
}
////////////////////////////
void del_Q (Queue &Q,Data x) {
Node *q = Q.pHead,*pp=Q.pTail;
if( empty_Q(Q) ) return;
else
{
if( Q.pHead == Q.pTail)
{
Q.pHead= Q.pHead=NULL;
}
else
{
while(pp->link!=Q.pHead) pp= pp->link;
x=Q.pHead->infor;
Q.pHead=pp;
Q.pHead->link=NULL;
}
free(q);
}
}
Data getQ(Queue&Q)
{
return Q.pHead->infor;
}
void doi_2_10()
{
char s[100];
int i,n;
int t=0;
Data x;
Queue Q;
printf("\n nhap so nhi phan:");
fflush(stdin);
gets(s);
printf("\n day so nhi phan vua nhap la: % s",s);
init_Q(Q);
n=strlen(s);
for(i=0;i<n;i++)
{
if(s[i]=='1')
x.dl=1*pow(2,n-i-1);
else
x.dl=0*pow(2,n-i-1);
}
while(!empty_Q(Q))
{
del_Q(Q,x);
t=t+x.dl;
}
printf("\n dang thap phan la:% d",t);
add_Q(Q,x);
}
int main()
{
doi_2_10();
getch();
return 0;
}