00XX吧 00XX吧
关注数: 15 粉丝数: 36 发帖数: 267 关注贴吧数: 4
能帮我看看代码吗? 这是建立一个链表的代码,在输出的时候不会输出第一项,查了好久还是不知道什么原因,希望有人能帮我看看,3Q very much!#include "stdio.h" #define node struct list #define newnode (node *)malloc(sizeof(node)) node *newlist(int n);                        /* 建立链表函数 */ node *output(node *p);                       /* 输出链表函数 */ struct data { int yy,mm,dd; }; node      {        char name[10],gender[3],adress[200],mobile[12],e_mail[32];        int n;        struct data brithday;        node *next;      }; main()     {          int n;          node *head,*p;          printf("你要建立几个人的信息?\n");          scanf("%d",&n);          head=newlist(n);          printf("数据如下\n");          p=head;          output(p);     } node *newlist(int n)                        /*   建立链表函数定义   */ {      node *head,*p,*q;      int i;      if(n<=0) head=NULL;      else              {                  head=newnode;                  p=head;                  printf("输入姓名: (最多4个字符)\n");                  scanf("%s",p->name);                  printf("输入性别: \n");                  scanf("%s",p->gender);                  printf("输入年份: (按年/月/日的格式)\n");                  scanf("%4d/%2d/%2d",&(*p).brithday.yy,&(*p).brithday.mm,&(*p).brithday.dd);
1 下一页