node*create_link();
void out_link(node*head);
int main()
{node *head=NULL;
head=create_link();
out_link(head);
cout<<"打印出总平均成绩:"< avg_link(head);
return 0;
}
node*create_link()
{node*head=NULL,*p,*q;
char no[4];
char name[10];
int eng,math,phy;
cout cin>>no;
head=new node;
strcpy(head->stu.no,no);
cin>>name;
strcpy(head->stu.name,name);
cin>>eng>>math>>phy;
head->stu.eng=eng;
head->stu.math=math;
head->stu.phy=phy;
q=head;
head->next=NULL;
cin>>no;
while(no[0]!='!')
{p=new node;
strcpy(p->stu.no,no);
cin>>name;
strcpy(p->stu.name,name);//=拷贝字符串时候只会拷贝首地址(第一个字符),而strcpy是把字符串里每个字符一个一个拷贝过去
cin>>eng>>math>>phy;
p->stu.eng=eng;
p->stu.math=math;
p->stu.phy=phy;
p->next=NULL;
q->next=p;
q=p;
cin>>no;
}
return head;
}
void out_link(node*head)
{node*p=head;
cout<<"输出数据:"< while(p!=NULL)
{coutstu.no<<'\t'<stu.name<<'\t'<stu.eng<<'\t'<stu.math<<'\t'<stu.phy<<'\t'< p=p->next;
}
}
void avg_link(node*head)
{node*p,*q;
int i,j,n,m;
p=head;
while(i=0,i<)
}
//建立链表的结点
struct stu{
int id;//学号
char name[16];//姓名
int eng,math,phy;
}
//建立一个链表的结构体,便于查找插入、删除的操作
struct LinkList{
stu *head; //这里设置一个头结点,不存放任何数据,用于遍历等操作
int size;//链表的大小(可以看你存放了多少个学生的数据)
}