求大神帮忙看看哪里错了!
c语言吧
全部回复
仅看楼主
level 2
霍世洁 楼主
#include<stdio.h>
#include<malloc.h>
typedef struct
{
int stack[200];
int top;
}seqstack;
seqstack *push(seqstack *p,int i)
{
p->stack[p->top]=i;
p->top++;
return(p);
}
void main()
{
int i,j,k;
do
{
printf("请输入需要转换的进制!\n");
fflush(stdin);
scanf("%d",&j);
}while(j>9||j<2);
printf("请输入需要转换的数!\n");
fflush(stdin);
scanf("%d",&i);
seqstack *p;
p=(seqstack *)malloc(sizeof(seqstack));
p->top=0;
while(i!=0&&p->top!=200)
{
k=i%j;
i=i/j;
p=push(p,k);
}
if(p->top==200)
printf("内存已满!");
else
{
printf("结果为:");
while(p->top!=0)
{
p->top--;
printf("%d",p->stack[p->top]);
}
printf("\n");
}
}
在转换到2进制时,如果数过大就不对了,是为啥?
2013年11月11日 10点11分 1
level 2
霍世洁 楼主
[不高兴]
2013年11月11日 10点11分 2
level 2
霍世洁 楼主
大神在哪?
[乖]
2013年11月11日 10点11分 3
level 2
霍世洁 楼主
[感动]
2013年11月11日 10点11分 4
level 2
霍世洁 楼主
[]大神——————————————————————————
2013年11月11日 10点11分 5
level 2
霍世洁 楼主
>_<>_<>_<#>_<>_<>_<>_<
2013年11月11日 10点11分 6
1