c语言,请帮帮忙,非常感谢啊!

来源:百度知道 编辑:UC知道 时间:2024/05/13 11:36:43
编写一个函数print,打印一个学生的成绩数组,该组中有n个学生的记录(n的值由键盘输入),每个记录包括 num,name,score[2],用main函数输入这些记录,用print函数输出这些记录.

要求是,只能用链表,结构体作。

# include "stdlib.h"
struct stu
{int num;
char name[8];
float score[2];
struct stu *next;};
main()
{struct *head,*p;
int n,i,j;
float temp;
head=(struct stu *)malloc(sizeof(struct stu));
p=head;
scanf("%d",&n);
for(i=0;i<n;i++)
{scanf("%d%s",&p->num,p->name);
for(j=0;j<2;j++)
{scanf("%f",&temp);
p->score[j]=temp;}
p->next=(struct stu *)malloc(sizeof(struct stu));
p=p->next;
p->next=NULL;}
p=head;
for(i=0;i<n;i++)
printf("%5d%10s%5.2f%5.2f\n",p->num,p->name,p->score[0],p->score[1]);
getch();}

我去年刚学的,忘啦,呵呵,不过你可以去网上别的地方查啊

#include <stdio.h>
#include <memory.h>
int n;
typedef struct _data
{
int num;
char* name;
int score[2];
}DATA,*DATA;
struct _datalist
{