#include <stdio.h>
#include <malloc.h>
typedef struct node{
int data;
struct node *link;
}NODE;
NODE *push(int m)
{
NODE *p,*top;
p=(NODE *)malloc(sizeof(NODE));
p->data =m;
p->link =top;
top=p;
return top;
}
NODE *pop(NODE *top)
{
NODE *q;
q=top;
top=top->link ;
free(q);
return top;
}
void conversion(int N,int r)
{
NODE *top1;
top1=(NODE *)malloc(sizeof(NODE));
int x=N,y=r;
while(N!=0)
{
top1=push(N%r);
N=N/r;
}
printf("\n十進制數%d所對應的%d進制數是:",x,y);
while(top1!=NULL)
{
printf("%d", top1=pop(top1));
}
printf("\n");
}
void main()
{
int n,r;
printf("請輸入任意一個十進制整數及其所需轉換的進制數:\n");
scanf("%d%d",&n,&r);
conversion(n,r);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/200452.html
標籤:C語言
上一篇:求幫助,急,介紹一下
