大佬,帮帮我啊啊啊 怎么一直是段错误啊
#include<stdio.h>#include<stdlib.h>
typedef struct{
int yushu;
}yu;
//yu *base,*top;
typedef struct sq{
struct sq *next;//必须的有struct
yu yu1;
//yu *top;
//int stacksize;
}sq;
//sq aa,*le=&aa;
sq *le,*le1;
sq *chuangjian(sq *le){
le=NULL;
//printf("1\n");
return le;
}
sq *ruzhan(sq *le,yu *yu2){//没有必要在加头结点//应该都为sq 类型指针 前插法
//printf("1\n");
le1=(sq *)malloc(sizeof(sq));
if(le1==NULL){
printf("增加节点失败了");
exit(1);
}
le1->yu1=*yu2;//改成这样在可以改变原函数的内容
le1->next=le;//->也属于间接访问
le=le1;
return le;
}
sq *chuzhan(sq *le,yu *yu2){
sq *le2;
if(le->next=NULL){
printf("站为空,不能出站");
exit(1);
}
le2=le;
*yu2=le->yu1;
//le1=le->next;
le=le->next;
free(le2);
return le;
}
int main(){
int x,a;
//sq *le,*le1;
yu *yu1;
//sq *le,*le1;
//yu *yu1;
//sq *le=&aa;
printf("请输入需要进行八进制转换的十进制数值是:");
scanf("%d",&x);
printf("请输入需要产生的多少进制数的数字:");
scanf("%d",&a);
printf("案件发开发");
le=chuangjian(le);
//printf("%p",le);
//printf("asdfasdf");
while(x/a){
printf("0");
yu1=(yu *)malloc(sizeof(yu));
if(yu1==NULL){
printf("失败");
exit(1);
}
printf("111111111111");
yu1->yushu=x%a;
le=ruzhan(le,yu1);
//le1->yu1.yushu=x%a;
x=x/a;
free(yu1);
}
printf("woshifdafihad");
yu1=(yu *)malloc(sizeof(yu));
if(yu1==NULL){
printf("失败");
exit(1);
}
yu1->yushu=x%a;
le=ruzhan(le,yu1);
x=x/a;
free(yu1);
while(le->next!=NULL){
yu1=(yu *)malloc(sizeof(yu));
if(yu1==NULL){
printf("创建失败");
exit(1);
}
//sq *le1;//为了让出站更好的释放节点
//le1=le;//为了让出站更好的释放节点
//le=le->next;//为了让出站更好的释放节点
le=chuzhan(le,yu1);
printf("%d ",yu1->yushu);
//le=le->next;
}
printf("%d ",le->yu1.yushu);
}
第一个调用时函数就有错误:段核心错误,瞪了一个小时了