#include "student_mag.h"
int main()
{
Node* head = malloc(sizeof(Node));
head->next = NULL;
while (1)
{
welcome();
char ch = _getch();
switch (ch)
{
case '1':
Inputstudent(head); //录入学生信息
break;
case '2':
Printstudent(head); //打印学生信息
break;
case '3':
Countstudent(head); //统计学生信息
break;
case '4':
Findstudent(head); //查找学生信息
break;
case '5':
break;
case '6':
break;
case '7':
break;
default:
break;
}
}
return 0;
}
void Inputstudent(Node* head) //输入学生信息
{
Node* fresh = malloc(sizeof(Node));
fresh->next = NULL;
printf("请输入学生信息\n");
scanf("%d%s%d", &fresh->stu.num, fresh->stu.name, &fresh->stu.sorce);
Node* move = head;
while (move->next!=NULL)
{
move = move->next;
}
move->next = fresh;
system("pause");
system("cls");
}
void Printstudent(Node* head)
{
Node* move = head->next;
while (move!=NULL)
{
printf("学号:%d,姓名:%s,分数:%d\n", move->stu.num, move->stu.name, move->stu.sorce);
move = move->next;
}
system("pause");
system("cls");
}
void Countstudent(Node* head)
{
int count = 0;
Node* move = head->next;
while (move!=NULL)
{
count++;
move = move->next;
}
printf("学生人数为%d\n", count);
system("pause");
system("cls");
}
void Findstudent(Node* head)
{
printf("请输入学生学号:");
int stunum;
scanf("%d", &stunum);
Node* move = head->next;
while (move!=NULL)
{
if (stunum == move->stu.num)
{
printf("学号:%d,姓名:%s,成绩%d\n", move->stu.num, move->stu.name, move->stu.sorce);
system("pause");
system("cls");
return;
}
move = move->next;
}
printf("未找到学生\n");
system("pause");
system("cls");
}