#include <iostream.h>
#include <stdlib.h>
typedef struct _num{
int bit;
_num *next;
}list;
typedef list *node;
void init(node &l){
l=NULL;
}
node GetNode(int x){
node p;
p=(node)malloc(sizeof(list));
if(p==NULL){
cout<<"Khong du bo nho!";
return NULL;
}
p->bit=x;
p->next=NULL;
return p;
}
node AddFirst(node &l,node p){
if(l==NULL){
l=p;
}
else{
p->next=l;
l=p;
}
}
void output(node l){
node p=l;
while(p!=NULL){
cout<<p->bit;
p=p->next;
}
cout<<endl;
}
int main(int argc, char *argv[])
{
node l;
int x=-1,tmp;
while(x<0){
cout<<"X=";
cin>>x;
}
while(x>=2){
tmp=x%2;
AddFirst(l,GetNode(tmp));
x/=2;
}
AddFirst(l,GetNode(x));
cout<<"He co so 2 cua x = ";
output(l);
return 0;
}
Pallet nhựa Lâm Đồng giải pháp hoàn hảo cho nhà kho Pallet nhựa Lâm Đồng là một giải pháp đa năng và hiệu quả trong việc vận chuyển và lưu trữ hàng hóa. Trong đó, pallet nhựa Lâm Đồng không chỉ đáp...
Pallet nhựa Lâm Đồng giải pháp...