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