自考没用:数据结构线性表

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 16:40:55
用线性表创建一个

姓名 学号 语文 数学

这样的表。表里的数据从键盘输入,该怎么做

要C源代码。

typedef struct note{
int xh;
char *xm;
int yw;
int shx;
struct note *next;
}*note;

/*输入姓名成绩*/

void input(note head,int xh,char *xm ,int yw,int shx)
{note p=head;
p=(note)malloc(sizeof(note));
p->xh=xh;
p->xm=xm;
p->yw=yw;
p->shx=shx;
head->next=p;
p->next=head->next;
}
/*输出信息*/
void output(note head)
{note p;
p=head;
while (p)
{printf("d%,\nc%\nd%\nd%",p->xh,p->xm,p->yw,p->shx);
p=p->next;
}
}

main()
{
int xh,yw,shx;
char *xm;
note head;
head=null;
scanf("%d,%s,%d,%d",&xh,xm,&yw,&shx);
input(head,xh,xm,yw,shx);
output(head);
}