学生信息管理系统——课程设计
使用C语言结构体,链表编写,实现了txt文本的读入和输出。角色分为普通用户和管理员
。系统初始化则到如用户数据
结构体设计及部分代码如下:
#include<stdio.h>
#include<string.h>
#include<math.h>
#include "malloc.h"
#include <stdlib.h>
#define LEN sizeof(struct Student)
#define LENUSER sizeof(struct User)
typedef struct Student
{
long num; /* 每个学生的学号 */
char name[10]; /* 每个学生的姓名 */
char course[20]; /* 每个学生课程名称 */
float course_score; /* 每个学生的总成绩 */
struct Student *next;
}STU;
typedef struct User
{
char username[30]; /* 用户名 */
char password[30]; /* 密码 */
int user_role; /* 用户角色 */
struct User *next;
}user;
int Login(user *head);
int Menu_Admin(void); //创建管理员菜单
int Menu_Persion(void); //创建用户菜单
void Print(STU *head); //打印函数
STU *Creat(int n); //创建链表并录入信息
STU *SortbyNum(STU *head); //按学号由小到大排出成绩表
void SearchbyNum(STU *head); //按学号查询学生信息
void SearchbyName(STU *head); //按姓名查询学生信息
void UpdatebyNum(STU *head); //按学号查询学生考试成绩和修改信息
void DeletebyNum(STU *head); //按学号查询学生考试成绩和修改信息
void StatisticAnalysis(STU *head); //按类别及比例输出
void WritetoFile(STU *head); //将每个学生的纪录信息写入文件
void ReadStufromFile(STU *head,char link[50]); //从文件中读出每个学生的信息
void ReadUserfromFile(user *head,char link[50]); //从文件中读出每个用户的信息
void dataInit(STU *head_stu,user *head_user); //初始化数据信息
int main()
{
int n, m=3,role;
int i;
STU *head_stu; //定义学生头节点
User *head_user; //定义用户头节点
head_stu = (STU *)malloc(LEN);
head_stu->next =NULL;
head_user = (User *)malloc(LENUSER);
head_user->next =NULL;
dataInit(head_stu,head_user);
role = Login(head_user);
if(role==1){
while (1)
{
i = Menu_Admin();
switch (i)
{
case 1:
system("cls"); //清屏
printf("\t\t\t******************************************************************************\n");
printf("\t\t\t请输入学生人数(n<30):\n"); //输入学生数
printf("\t\t\t");
scanf("%d", &n);
printf("\t\t\t请输入学生的学号 姓名 语文 数学 英语成绩:\n");
head_stu->next = Creat(n);
system("cls"); //清屏
break;
case 2:
system("cls"); //清屏
SearchbyName(head_stu);
break;
case 3:
system("cls"); //清屏
SearchbyNum(head_stu);
break;
case 4:
system("cls"); //清屏
printf("\n\n\n");
DeletebyNum(head_stu);
break;
case 5:
system("cls"); //清屏
printf("\n\n\n");
StatisticAnalysis(head_stu);
break;
case 6:
system("cls"); //清屏
printf("\n\n\n");
printf("\t\t\t******************************************************************************\n");
printf("\t\t\t输入你想查询的学生ID:\n");
UpdatebyNum(head_stu);
break;
case 7:
system("cls"); //清屏
printf("\n\n\n");
Print(head_stu);
break;
case 8:
system("cls"); //清屏
WritetoFile(head_stu);
break;
case 9:
system("cls"); //清屏
// ReadStufromFile(head_stu);
break;
case 0:
system("cls"); //清屏
printf("\n\n\n");
printf("\t\t\t******************************************************************************\n");
printf("\t\t\tEnd of program!\n");
printf("\t\t\t******************************************************************************\n");
return 0;
default:
system("cls"); //清屏
printf("\n\n\n");
printf("\t\t\t******************************************************************************\n");
printf("\t\t\tInput error!\n");
printf("\t\t\t******************************************************************************\n");
}
}
}else{
while(1){
i = Menu_Persion();
switch (i)
{
case 1:
system("cls"); //清屏
SearchbyName(head_stu);
break;
case 2:
system("cls"); //清屏
SearchbyNum(head_stu);
break;
case 3:
system("cls"); //清屏
printf("\n\n\n");
Print(head_stu);
break;
case 0:
system("cls"); //清屏
printf("\n\n\n");
printf("\t\t\t******************************************************************************\n");
printf("\t\t\tEnd of program!\n");
printf("\t\t\t******************************************************************************\n");
return 0;
default:
system("cls"); //清屏
printf("\n\n\n");
printf("\t\t\t******************************************************************************\n");
printf("\t\t\tInput error!\n");
printf("\t\t\t******************************************************************************\n");
}
}
}
return 0;
}
关注可私聊获取源码
下载链接:https://download.csdn.net/download/weixin_44546342/17065245?spm=1001.2014.3001.5503