液压支撑杆缺点:填注释啊(急需)

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 13:03:38
#include<stdio.h>
#include<stdlib.h>
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
long num;
int score[3];
int all;
struct student *next;
};
int n;
struct student *creat(void)
{
struct student *head;
struct student *p1,*p2;
int i=1,j;
n=0;
p1=p2=(struct student *)malloc(LEN);
printf("input the student%d record:\n",i);
printf("num:");
scanf("%ld",&p1->num);
p1->all=0;
for(j=0;j<3;j++)
{
printf("score%d:",j);
scanf("%d",&p1->score[j]);
p1->all=p1->all+p1->score[j];
}
i=i+1;
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
printf("input the student%d record:\n",i);
printf("num:");
scanf("%ld",&p1->num);
p1->all=0;
for(j=0;j<3;j++)
{
printf("score%d:",j);
scanf("%d",&p1->score[j]);
p1->all=p1->all+p1->score[j];
}
i=i+1;
}
p2->next=NULL;
return(head);
}
struct student *insert(struct student *p)
{
struct student *head,*p1,*stu;
int j;
stu=(struct student *)malloc(LEN);
printf("input the insert student record:\n");
printf("num:");
scanf("%ld",&stu->num);
stu->all=0;
for(j=0;j<3;j++)
{
printf("score%d:",j);
scanf("%d",&stu->score[j]);
stu->all=stu->all+stu->score[j];
}
head=p;
if(head==NULL) {head=stu;stu->next=NULL;} /*stu结点的next
p1=head;
while(stu->num!=p1->num&&p1->next!=NULL)
p1=p1->next;
if(stu->num==p1->num) printf("\nerroe\n");
else
{
p1->next=stu;stu->next=NULL;n=n+1;
}
return(head);
}
struct student *modify(struct student *p)
{
struct student *head,*p1,*stu;
int j;
stu=(struct student *)malloc(LEN); printf("input the modify student record:\n");
printf("num:");
scanf("%ld",&stu->num);
stu->all=0;
for(j=0;j<3;j++)
{
printf("score%d:",j);
scanf("%d",&stu->score[j]);
stu->all=stu->all+stu->score[j];
}
head=p;
if(head==NULL) {printf("\nerror\n");}
p1=head;
while(stu->num!=p1->num&&p1->next!=NULL)
p1=p1->next;
if(stu->num==p1->num)
{
p1->num=stu->num;
p1->score[0]=stu->score[0];
p1->score[1]=stu->score[1];
p1->score[2]=stu->score[2];
p1->all=stu->all;
}
else printf("\nerror\n");
return(head);
}

sb