为了账号安全,请及时绑定邮箱和手机立即绑定

大神快看看我的动态链表哪里错了

大神快看看我的动态链表哪里错了

C
DOUBLE_l 2016-11-30 22:54:02
#include <stdio.h> #include <stdlib.h> typedef struct Date{ int year; int month; int day; struct Date* next;}date; void main() { int i; date*head,*p,*p1; *p=(date*)malloc(sizeof(date)); p1=head=p; for(;p->next!=NULL;) { scanf("%d,%d,%d",&p->year,&p->month,&p->day); if(p->year==0&&&p->month==0&&p->day==0) {p->next=NULL;continue;} *p=*p=(date*)malloc(sizeof(date)); p1->next=p; p1=p; } for(;head->next!=NULL;) { printf("%d,%d,%d\n"head->year,head->month,head->day); } }
查看完整描述

3 回答

?
DOUBLE_l

TA贡献45条经验 获得超12个赞

#include <stdio.h> #include <stdlib.h> typedef struct Date{ int year; int month; int day; struct Date* next;}date; void main() { int i; date*head,*p,*p1; *p=(date*)malloc(sizeof(date)); p1=head=p; for(;p->next!=NULL;) { scanf("%d,%d,%d",&p->year,&p->month,&p->day); if(p->year==0&&&p->month==0&&p->day==0) {p->next=NULL;continue;} *p=*p=(date*)malloc(sizeof(date)); p1->next=p; p1=p; } for(;head->next!=NULL;) { printf("%d,%d,%d\n"head->year,head->month,head->day); } }快看看,
查看完整回答
反对 回复 2016-11-30
  • 3 回答
  • 0 关注
  • 1361 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信