|
|
@ -15,9 +15,9 @@ struct node //
|
|
|
|
node *next;//指针
|
|
|
|
node *next;//指针
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
node *create()//创建学生信息
|
|
|
|
node *create()//创建学生成绩信息
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct node * head,* p,* q; //*p指向头,而*q指向尾。
|
|
|
|
struct node * head,* p,* q; //*head第一个的头,*q指向头,而*p指向尾。
|
|
|
|
int number;
|
|
|
|
int number;
|
|
|
|
char sname[15];
|
|
|
|
char sname[15];
|
|
|
|
int sgs,syy,sc;
|
|
|
|
int sgs,syy,sc;
|
|
|
@ -59,9 +59,9 @@ node *create()//
|
|
|
|
q->yy=syy;//赋值
|
|
|
|
q->yy=syy;//赋值
|
|
|
|
q->c=sc;//赋值
|
|
|
|
q->c=sc;//赋值
|
|
|
|
strcpy(q->name,sname);//赋值
|
|
|
|
strcpy(q->name,sname);//赋值
|
|
|
|
q->next=NULL;//q指向下个结构体的尾部,指针域为空
|
|
|
|
q->next=NULL; //q指针指向新创建的节点
|
|
|
|
p->next=q; //
|
|
|
|
p->next=q; // p是指向当前链表的最后一个节点,这个节点的next是空
|
|
|
|
p=q;
|
|
|
|
p=q; //p始终指向链表的尾部节点
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return head;//返回头结点
|
|
|
|
return head;//返回头结点
|
|
|
@ -69,7 +69,7 @@ node *create()//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node *jiaru(node *head)//添加学生信息
|
|
|
|
node *jiaru(node *head)//添加学生成绩信息
|
|
|
|
{
|
|
|
|
{
|
|
|
|
node *p,* q;
|
|
|
|
node *p,* q;
|
|
|
|
int number;
|
|
|
|
int number;
|
|
|
@ -107,52 +107,7 @@ node *jiaru(node *head)//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node * delete_name(node *head)//按姓名删除学生信息
|
|
|
|
node * delete_i(node *head)//按学号删除学生成绩信息
|
|
|
|
{
|
|
|
|
|
|
|
|
node *b,*p;
|
|
|
|
|
|
|
|
p=head;
|
|
|
|
|
|
|
|
char qname[15];
|
|
|
|
|
|
|
|
char c;
|
|
|
|
|
|
|
|
printf("请输入要删除学生姓名:");
|
|
|
|
|
|
|
|
scanf("%s",&qname);//输入要删除学生姓名
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(p==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return head;//若信息为空则返回原头结点
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(p->name,qname)==0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("确认删除y/n:");
|
|
|
|
|
|
|
|
scanf("%s",&c);
|
|
|
|
|
|
|
|
if(c=='y')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(p==head)//判断头指针
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
head=p->next;
|
|
|
|
|
|
|
|
free(p);//释放内存空间
|
|
|
|
|
|
|
|
printf("删除成功!\n");
|
|
|
|
|
|
|
|
return head;//返回头结点
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
b->next=p->next;//使p结点后面的链表和前面的链表连接
|
|
|
|
|
|
|
|
free(p);//释放内存空间
|
|
|
|
|
|
|
|
printf("删除成功!\n");
|
|
|
|
|
|
|
|
return head;//返回头结点
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
printf("退出删除!\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
b=p;
|
|
|
|
|
|
|
|
p=p->next;//向下一个结点
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("删除出错!\n");
|
|
|
|
|
|
|
|
return head;//返回头结点
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node * delete_i(node *head)//按学号删除学生信息
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
node *b,*p;
|
|
|
|
node *b,*p;
|
|
|
|
p=head;
|
|
|
|
p=head;
|
|
|
@ -198,7 +153,7 @@ node * delete_i(node *head)//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int query_name(node * head)//按姓名查找学生信息
|
|
|
|
int query_name(node * head)//按姓名查找学生成绩信息
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct node * p;
|
|
|
|
struct node * p;
|
|
|
|
char sname[20];
|
|
|
|
char sname[20];
|
|
|
@ -220,7 +175,7 @@ int query_name(node * head)//
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int query_i(node * head)//按学号查找学生信息
|
|
|
|
int query_i(node * head)//按学号查找学生成绩信息
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct node * p;
|
|
|
|
struct node * p;
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
@ -243,6 +198,8 @@ int query_i(node * head)//
|
|
|
|
printf("没有找到!!!\n");
|
|
|
|
printf("没有找到!!!\n");
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int install_name(node * head)//插入学生信息到某姓名学生之后
|
|
|
|
int install_name(node * head)//插入学生信息到某姓名学生之后
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct node *p,*n;
|
|
|
|
struct node *p,*n;
|
|
|
@ -316,7 +273,7 @@ int install_i(node * head)//
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int xiugai_name(node *head)//通过姓名修改学生信息
|
|
|
|
int xiugai_name(node *head)//通过姓名修改学生成绩信息
|
|
|
|
{
|
|
|
|
{
|
|
|
|
node *p;
|
|
|
|
node *p;
|
|
|
|
p=head;
|
|
|
|
p=head;
|
|
|
@ -353,7 +310,7 @@ int xiugai_name(node *head)//ͨ
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int xiugai_i(node *head)//通过学号修改学生信息
|
|
|
|
int xiugai_i(node *head)//通过学号修改学生成绩信息
|
|
|
|
{
|
|
|
|
{
|
|
|
|
node *p;
|
|
|
|
node *p;
|
|
|
|
p=head;
|
|
|
|
p=head;
|
|
|
@ -390,7 +347,7 @@ int xiugai_i(node *head)//ͨ
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void printf(node * head)//输出所有信息
|
|
|
|
void printf(node * head)//输出所有成绩信息
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
FILE *fp;
|
|
|
|
char buf[BUFSIZE];
|
|
|
|
char buf[BUFSIZE];
|
|
|
@ -432,27 +389,25 @@ int main()//
|
|
|
|
printf("*********************************************\n");
|
|
|
|
printf("*********************************************\n");
|
|
|
|
while(1)
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf(" * 1.输入信息 *\n");
|
|
|
|
printf(" * 1.输入学生成绩信息(只能使用一次) *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * 2.添加学生信息 *\n");
|
|
|
|
printf(" * 2.添加学生成绩信息 *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * 3.根据姓名查找学生信息 *\n");
|
|
|
|
printf(" * 3.根据姓名查找学生成绩信息 *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * 4.根据学号查找学生信息 *\n");
|
|
|
|
printf(" * 4.根据学号查找学生成绩信息 *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * 5.根据姓名删除学生信息 *\n");
|
|
|
|
printf(" * 5.根据学号删除学生成绩信息 *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * 6.根据学号删除学生信息 *\n");
|
|
|
|
printf(" * 6.根据姓名修改学生成绩信息 *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * 7.根据姓名修改学生信息 *\n");
|
|
|
|
printf(" * 7.根据学号修改学生成绩信息 *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * 8.根据学号修改学生信息 *\n");
|
|
|
|
printf(" * 8.插入学生成绩信息到某姓名学生之后 *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * 9.插入学生信息到某姓名学生之后 *\n");
|
|
|
|
printf(" * 9.插入学生成绩信息到第几位学生之后 *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * 10.插入学生信息到第几位学生之后 *\n");
|
|
|
|
printf(" * 10.输出所有学生成绩信息 *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
|
|
|
|
printf(" * 11.输出所有学生信息 *\n");
|
|
|
|
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * *\n");
|
|
|
|
printf(" * 0.退出 *\n\n");
|
|
|
|
printf(" * 0.退出 *\n\n");
|
|
|
|
printf("请选择操作:");
|
|
|
|
printf("请选择操作:");
|
|
|
@ -466,18 +421,16 @@ int main()//
|
|
|
|
if(n==4)
|
|
|
|
if(n==4)
|
|
|
|
query_i(head);
|
|
|
|
query_i(head);
|
|
|
|
if(n==5)
|
|
|
|
if(n==5)
|
|
|
|
head=delete_name(head);
|
|
|
|
|
|
|
|
if(n==6)
|
|
|
|
|
|
|
|
head=delete_i(head);
|
|
|
|
head=delete_i(head);
|
|
|
|
if(n==7)
|
|
|
|
if(n==6)
|
|
|
|
xiugai_name(head);
|
|
|
|
xiugai_name(head);
|
|
|
|
if(n==8)
|
|
|
|
if(n==7)
|
|
|
|
xiugai_i(head);
|
|
|
|
xiugai_i(head);
|
|
|
|
if(n==9)
|
|
|
|
if(n==8)
|
|
|
|
install_name(head);
|
|
|
|
install_name(head);
|
|
|
|
if(n==10)
|
|
|
|
if(n==9)
|
|
|
|
install_i(head);
|
|
|
|
install_i(head);
|
|
|
|
if(n==11)
|
|
|
|
if(n==10)
|
|
|
|
printf(head);
|
|
|
|
printf(head);
|
|
|
|
if(n==0)
|
|
|
|
if(n==0)
|
|
|
|
{
|
|
|
|
{
|