#include
#include//含malloc.h
#define LEN sizeof( Faction)
//一元多项式结构体
typedef struct Faction{
int coefficient;//系数
int exponent;//指数
struct Faction next;
}Faction;
//创建链表
Faction *creat() {
Faction *head, *p1, *p2;
head = NULL;
p1 = p2 = (Faction)malloc(LEN);
scanf("d% d%", &(p1->coefficient), &(p1->exponent));
p1->next = NULL;
while(p1->coefficient != -1 || p1->exponent != -1) {
if(head == NULL)
head = p1;
else
p2->next = p1;
p2 = p1;
p1 = (Faction*)malloc(LEN);
scanf("d% d%", &(p1->coefficient), &(p1->exponent));
}
p2->next = NULL;
return head;
}
//输出链表
void Print(Faction *head) {
Faction *p;
p = head;
while(head != NULL) {
printf("d% d%", p->coefficient, p->exponent);
p = p->next;
}
}
//
int main() {
Faction *head;
head = NULL;
head = creat();
Print(head);
return 0;
}
请问为什么这段代码输入两个数之后回车会死机?
C语言(数据结构)链表创建问题
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
5条回答 默认 最新
悬赏问题
- ¥15 素材场景中光线烘焙后灯光失效
- ¥15 请教一下各位,为什么我这个没有实现模拟点击
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 ubuntu子系统密码忘记
- ¥15 保护模式-系统加载-段寄存器