|
|
/*初始化链表*/
|
|
|
void InitList(Lnode *&head)
|
|
|
{
|
|
|
head = (Lnode *)malloc(sizeof(Lnode));
|
|
|
if (head == NULL)
|
|
|
{
|
|
|
printf("error!");
|
|
|
exit(1);
|
|
|
}
|
|
|
head->next = NULL; //使头节点指针域为空
|
|
|
}
|
|
|
|
|
|
int main()
|
|
|
{
|
|
|
Lnode *ScoreList; //建立成绩链表,所有学生信息存放在此链表
|
|
|
int Function;
|
|
|
char flag;
|
|
|
int t = 0;
|
|
|
InitList(ScoreList);
|
|
|
LoadInf(ScoreList);
|
|
|
|
|
|
while (1)
|
|
|
{
|
|
|
Display();
|
|
|
printf("请选择操作: ");
|
|
|
scanf("%d", &Function);
|
|
|
switch (Function)
|
|
|
{
|
|
|
case 1: while (1)
|
|
|
{
|
|
|
GetScore(ScoreList);
|
|
|
printf("是否继续输入 (Y/N)");
|
|
|
scanf("%s", &flag);
|
|
|
if (flag == 'N' || flag == 'n')break;
|
|
|
} system("cls"); break;
|
|
|
case 2: PrintScore(ScoreList); _getch(); system("cls"); break;
|
|
|
case 3: ModifyScore(ScoreList); system("cls"); break;
|
|
|
case 4: FindInf(ScoreList); _getch(); system("cls"); break;
|
|
|
case 5: Delete(ScoreList); _getch(); system("cls"); break;
|
|
|
case 6: Quit(ScoreList); break;
|
|
|
|
|
|
default: printf("Error!!! 请重新输入:");
|
|
|
break;
|
|
|
} //switch结束
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/*系统界面显示*/
|
|
|
void Display()
|
|
|
{
|
|
|
printf("\t\t**********************************************\n");
|
|
|
printf("\t\t*************欢迎使用成绩管理系统*************\n");
|
|
|
printf("\t\t**********************************************\n");
|
|
|
printf("\t\t\t\t1、录入成绩\n");
|
|
|
printf("\t\t\t\t2、打印成绩\n");
|
|
|
printf("\t\t\t\t3、修改成绩\n");
|
|
|
printf("\t\t\t\t4、查找学生信息\n");
|
|
|
printf("\t\t\t\t5、删除学生信息\n");
|
|
|
printf("\t\t\t\t6、退出系统\n");
|
|
|
printf("\n\n\n\n\n\n");
|
|
|
}
|
|
|
|
|
|
/*成绩录入*/
|
|
|
void GetScore(Lnode *&h)
|
|
|
{
|
|
|
Lnode *p, *q = h;
|
|
|
char name[10], id[15];
|
|
|
int Math, English, Datastruct;
|
|
|
p = (Lnode *)malloc(sizeof(Lnode)); //为学生信息申请节点
|
|
|
printf("请依次输入学生信息:\n");
|
|
|
printf("姓名 学号 数学 英语 数据结构\n");
|
|
|
scanf("%s %s %d %d %d", &name, &id, &Math, &English, &Datastruct);
|
|
|
|
|
|
for (; q->next != NULL; q = q->next){;} //移动到尾节点
|
|
|
|
|
|
strcpy(p->Name, name);
|
|
|
strcpy(p->ID, id);
|
|
|
p->Score[0] = Math;
|
|
|
p->Score[1] = English;
|
|
|
p->Score[2] = Datastruct;
|
|
|
p->Ave_Sco = ((float)((p->Score[0] + p->Score[1] + p->Score[2]) - 150)) / 30;
|
|
|
|
|
|
p->next = NULL;
|
|
|
q->next = p;
|
|
|
q = p;
|
|
|
}
|