大家好,现在需要做一个C语言的成绩查询系统。做出来成这样

如题所述

#include <stdio.h>
#include <stdlib.h>

typedef struct student *ST;
struct student
{
int stNu;
int stVal;
int stMat;
int stEng;
ST next;
};
ST head = NULL;
int ShowNode()
{
int no;
ST t;

printf("输入学号:");
scanf("%d", &no);
for (t = head; t; t = t->next)
{
if (t->stNu == no)
{
printf("学号:%d, 语文:%d 数学:%d 英语:%d\n", t->stNu, t->stVal, t->stMat, t->stEng);
return 0;
}
}
printf("无此学生\n");
return 0;
}

int ChangeNode()
{
int no;
ST t;

printf("输入学号:");
scanf("%d", &no);
for (t = head; t; t = t->next)
{
if (t->stNu == no)
{
printf("输入新的成绩:");
printf("语文成绩:");
scanf("%d", &t->stVal);
printf("数学成绩:");
scanf("%d", &t->stMat);
printf("英语成绩:");
scanf("%d", &t->stEng);
return 0;
}
}
printf("无此学生\n");
return 0;
}

int InsertNode()
{
ST t;
t = (ST)malloc(sizeof *t);
printf("输入学号:");
scanf("%d", &t->stNu);
printf("输入语文成绩:");
scanf("%d", &t->stVal);
printf("输入数学成绩:");
scanf("%d", &t->stMat);
printf("输入英语成绩:");
scanf("%d", &t->stEng);
t->next = head;
head = t;
return 0;
}

int DelNode()
{
ST x, y;
int no;

printf("输入学号:");
scanf("%d", &no);
for (x = y = head; x; y = x, x = x->next)
{
if (x->stNu == no)
{
if (x ==y)
{
x = head = head->next;
y->next = NULL;
free(y);
return 0;
}
else
{
y->next = x->next;
x->next = NULL;
free(x);
return 0;
}
}
}
printf("无此学生\n");
return 0;
}

int main(void)
{
int i;
while(1)
{
printf("查询成绩:1\n"
"更改成绩:2\n"
"插入成绩:3\n"
"删除学生:4\n"
"退出:5\n");
scanf("%d", &i);
if (1==i)
{
ShowNode();
}
else if(2==i)
{
ChangeNode();
}
else if(3==i)
{
InsertNode();
}
else if(4==i)
{
DelNode();
}
else if(5==i)
{
break;
}
else
{
printf("输入错误!请重新输入!\n");
continue;
}
}
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-05-07
这样的功能 我可以解决的追问

大神

追答

不客气 看名

追问

帮帮我 谢啦😘

输入0到6要有对应功能哦

追答

没看我的名吗?找我来

追问

什么意思啊

追答

我的用户名

相似回答