要求在代码中添加一个功能,显示两科及两科以上不及格的学生名单,我插入的代码在void Viewall中,在** **中间,运行中无法显示学生名单,只能显示姓名:null
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#define LEN sizeof(struct Student)
struct Student{
char name[10];
char number[20];
int C_Language;
int Math;
int English;
struct Student* next;
};
struct Student* head = NULL;
struct Student* end = NULL;
void Menu(){
void Menu();
void Add();
void View();
void Delete();
void Repair();
void ViewAll();
system("cls");
printf("1、学生信息录入\n");
printf("2、学生单个成绩查询\n");
printf("3、查询全部学生成绩\n");
printf("4、修改学生信息\n");
printf("5、删除学生信息\n");
printf("6、退出系统\n");
int choice;
printf("请选择要使用的功能:\n");
loop:
scanf("%d",&choice);
switch (choice) {
case 1:
Add();
Menu();
case 2:
View();
Menu();
case 3:
ViewAll();
Menu();
case 4:
Repair();
Menu();
case 5:
Delete();
Menu();
case 6:
exit(0);
default:
printf("输入有误,请重新选择:");
break;
}
}
void Add(){
system("cls");
int count;
printf("请输入要录入信息的个数:");
scanf("%d",&count);
struct Student *s1,*s2,*temp;
s1=s2=(struct Student*)malloc(LEN);
if(head==NULL){
head = s1;
}else{
end->next = s1 ;
}
int i = 1;
while(count>0){
printf("请输入第%d位学生信息:\n",i++);
printf("姓名:\n");
scanf("%s",&s1->name);
printf("学号:\n");
scanf("%s",&s1->number);
printf("C语言成绩:\n");
scanf("%d",&s1->C_Language);
printf("数学成绩:\n");
scanf("%d",&s1->Math);
printf("英语成绩:\n");
scanf("%d",&s1->English);
count--;
s2->next=s1;
s2=s1;
s1=(struct Student*)malloc(LEN);
printf("添加成功!\n");
system("pause");
system("cls");
}
s2->next= NULL;
end = s2;
printf("全部添加成功!\n");
system("pause");
}
void View(){
system("cls");
struct Student *VS;
printf("输入要查询信息的学生学号:\n");
char num[10];
int flag=1;
scanf("%s",&num);
for(VS=head;VS!=NULL;){
if(strcmp(VS->number,num)==0){
printf("成功找到!\n");
printf("姓名:%s\t学号:%s\t\n",VS->number,VS->name);
printf("C语言:%d\t数学:%d\t英语:%d",VS->C_Language,VS->Math,VS->English);
flag=0;
break;
}
VS=VS->next;
}
if(flag){
printf("不好意思,未找到!\n");
}
system("pause");
}
void ViewAll(){
system("cls");
struct Student *VA;
if(head!=NULL){
printf("所有学生成绩如下:\n");
for(VA=head;VA!=NULL;){
printf("姓名:%s\t学号:%s\t\n",VA->name,VA->number);
printf("C语言:%d\t数学:%d\t英语:%d\n",VA->C_Language,VA->Math,VA->English);
VA=VA->next;
}
}else{
printf("该系统中还未录入信息");
}
**int C_Language;
int Math;
int English;
if(C_Language<60 && Math<60 || C_Language<60 && English<60 ||Math<60 && English<60 || C_Language<60 && English<60
&& Math<60){
printf("所有不及格科目超过两科的学生名单如下:\n");
printf("姓名:%s\t\n",VA->name);
}**
system("pause");
}
void Repair(){
system("cls");
struct Student *RS;
char num[10];
int flag = 1;
printf("输入要修改成绩学生的学号:\n");
scanf("%s",num);
for(RS=head;RS!=NULL;){
if(strcmp(RS->number,num)==0){
printf("成功找到该学生");
printf("姓名:%s\t学号:%s\t\n",RS->number,RS->name);
printf("C语言:%d\t数学:%d\t英语:%d\n",RS->C_Language,RS->Math,RS->English);
flag = 0;
printf("姓名:\n");
scanf("%s",&RS->name);
printf("学号:\n");
scanf("%s",&RS->number);
printf("C语言成绩:\n");
scanf("%d",&RS->C_Language);
printf("数学成绩:\n");
scanf("%d",&RS->Math);
printf("英语成绩:\n");
scanf("%d",&RS->English);
printf("修改成功");
system("pause");
}
RS=RS->next;
}
if(flag){
printf("输入信息有误,未查询到");
system("pause");
}
}
void Delete(){
system("cls");
int flag =1;
while(flag){
printf("请输入要删除的学生学号:");
char num[10];
scanf("%s",&num);
struct Student * DS,*temp;
for(DS=head;DS!=NULL;){
if(strcmp(DS->number,num)==0){
if(DS==head){
head = DS->next;
flag = 0;
printf("删除成功!\n");
system("pause");
}else{
flag = 0;
printf("删除成功!\n");
temp->next= DS->next;
free(DS);
system("pause");
}
}
temp = DS;
DS=DS->next;
}
if(flag){
printf("未找到该学生学号!\n");
system("pause");
}
}
}
struct score{
int C_Language;
int Math;
int English;
}Score;
int main(){
void Menu();
void Add();
void View();
void Delete();
void Repair();
void ViewAll();
Menu();
}