#include "function.h"
#include <io.h>
#include <windows.h>
/*设置输出颜色*/
int Color(int c)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c);
return 0;
}
/*使用说明*/
void ShowHelp(char* autor,char *date)
{
printf("\n");
printf("\t**********************************************\n");
printf("\t*\t\t使用说明\n");
printf("\t*1:本系统分为教职工管理系统,学生管理系统,成绩管理系统三部分,各系统均可进行增删改查操作\n");
printf("\t*2:选择相应的编号输入并回车即可进行相应操作\n");
printf("\t*3:本系统由可执行程序[教学管理系统.exe]及数据文档[.dat]组成,当无数据文档时,会默认为初次使用,重新生成文档\n");
printf("\t*4:转移数据文档仅需转移数据文档[.dat]即可\n");
printf("\t*5:本系统不适合存储大型数据.\n");
printf("\t*\t\t\t作者:%s\n", autor);
printf("\t*\t\t\t时间:%s\n", date);
printf("\t**********************************************\n");
}
//用户输入密码
void InputPassWord(char getPW[MAX])
{
char theChar;
int i = 0;
for (; i < MAX - 1; i++)
{
theChar = getch();
if (theChar == 13)
{
break;
}
else
{
getPW[i] = theChar;
printf("*");
}
}
}
//增加用户
int AddUser(char* ID, char* passWord, int leve)
{
FILE* file = fopen("infor.dat", "a+");
if (!file)
{
return -1;
}
User* tempUser = (User*)malloc(sizeof(User));
strcpy(tempUser->ID, ID);
strcpy(tempUser->Password, passWord);
tempUser->leve = leve;
fwrite(tempUser, sizeof(User), 1, file);
fclose(file);
return 0;
}
//登录判断
int Land(char* ID, char *passWord)
{
if (access("./infor.dat", 0) < 0)
{
AddUser("user","123456", 9);
return -1;
}
FILE* file = fopen("infor.dat", "rb");
if (!file)
{
return -2;
}
User *userlist = (User*)malloc(sizeof(User));
User* str = userlist;
strcpy(userlist->ID,"ID");
strcpy(userlist->Password, "PassWord");
userlist->leve = 0;
User *tempUser= (User*)malloc(sizeof(User));
fread(tempUser, sizeof(User), 1, file);
while (!feof(file)) //一直读到文件末尾
{
userlist->next = tempUser;
userlist = tempUser;
tempUser = (User*)malloc(sizeof(User));
fread(tempUser, sizeof(User), 1, file);
} //while循环结束
userlist->next = NULL;
while (str->next)
{
if (strcmp(str->next->ID, ID) == 0 && strcmp(str->next->Password, passWord) == 0)
{
return str->next->leve;
}
else {
str = str->next;
}
}
fclose(file);
return -1;
}
//删除用户
int DeleUser(char* ID, char* passWord)
{
if (access("./infor.dat", 0) < 0)
{
FILE* file = fopen("infor.dat", "wb");
fclose(file);
return -1;
}
FILE* file = fopen("infor.dat", "rb");
if (!file)
{
return -2;
}
User* userlist = (User*)malloc(sizeof(User));
strcpy(userlist->ID, "ID");
strcpy(userlist->Password, "PassWord");
userlist->leve = 0;
User* tempUser = (User*)malloc(sizeof(User));
fread(tempUser, sizeof(User), 1, file);
User* str1 = userlist;
while (!feof(file)) //一直读到文件末尾
{
str1->next = tempUser;
str1 = tempUser;
tempUser = (User*)malloc(sizeof(User));
fread(tempUser, sizeof(User), 1, file);
} //while循环结束
fclose(file);
User* str2 = userlist;
User* str3 = str2->next;
while (str2->next)
{
if (strcmp(str2->next->ID, ID) == 0 && strcmp(str2->next->Password, passWord) == 0)
{
str2->next = str3->next;
free(str3);
file = fopen("./infor.dat", "wb");
while (userlist->next)
{
fwrite(userlist->next, sizeof(User), 1, file);
userlist=userlist->next;
}
fclose(file);
return 0;
}
else
{
str2 = str2->next;
str3 = str3->next;
}
}
return -1;
}
/*初始化成绩链表*/
int InitScoreList(Score *&head)
{
head = (Score *)malloc(sizeof(Score));
if (head == NULL)
{
printf("错误,请检查内存后重新进入.\n");
return -1;
}
strcpy(head->Name,"科目");
strcpy(head->score, "分数");
strcpy(head->Owner, "姓名");
strcpy(head->OID, "ID");
head->next = NULL; //使头节点指针域为空
return 0;
}
/*初始化学生链表*/
int InitStudentList(Student *&head)
{
head = (Student *)malloc(sizeof(Student));
if (head == NULL)
{
printf("错误,请检查内存后重新进入.\n");
exit(-1);
return -1;
}
strcpy(head->ID, "ID");
strcpy(head->Name, "姓名");
strcpy(head->theclass, "班级");
head->next = NULL; //使头节点指针域为空
return 0;
}
/*初始化教职工链表*/
int InitTeacherList(Teacher *&head)
{
head = (Teacher *)malloc(sizeof(Teacher));
if (head == NULL)
{
printf("错误,请检查内存后重新进入.\n");
exit(1);
return -1;
}
strcpy(head->ID, "ID");
strcpy(head->Name, "姓名");
strcpy(head->position, "职位");
head->next = NULL; //使头节点指针域为空
return 0;
}
/*登记学生*/
int AddStudent(Student *&head)
{
Student *p,*q = head;
char name[10], id[15],theClass[20];
p = (Student *)malloc(sizeof(Student)); //为学生信息申请节点
printf("请依次输入学生信息:\n");
printf("|姓名| 学号| 班级|\n ");
scanf("%s %s %s", &name, &id, &theClass);
strcpy(p->Name, name);
strcpy(p->ID, id);
strcpy(p->theclass,theClass);
p->next = NULL;
for (; q->next != NULL; q = q->next) { ; } //移动到尾节点
q->next = p;
q = p;
printf("\n录入成功!\n");
_getch();
return 0;
}
/*登记教职工*/
int AddTeacher(Teacher *&head)
{
Teacher *p,*q = head;
char name[10], id[15], position[20];
p = (Teacher *)malloc(sizeof(Teacher)); //为学生信息申请节点
printf("请依次输入教职工信息:\n");
printf("|姓名| 职工号| 职位|\n ");
int num=scanf(" %s %s %s", name, id, position);
strcpy(p->Name, name);
strcpy(p->ID, id);
strcpy(p->position, position);
p->next = NULL;
for (; q->next != NULL; q = q->next) { ; } //移动到尾节点
q->next = p;
q = p;
printf("\n录入成功!\n");
_getch();
return 0;
}
/*登记成绩*/
int AddScore(Score *&head)
{
Score *sco = head;
char id[30], ower[30],name[30], sroce[30];
printf("请依次输入成绩信息:\n");
printf("|学生ID|姓名|课程|分数|\n");
scanf("%s %s %s %s", id,ower, name, sroce);
Score * temp = (Score *)malloc(sizeof(Score));
strcpy(temp->Name, name);
strcpy(temp->OID, id);
strcpy(temp->Owner, ower);
strcpy(temp->score, sroce);
temp->next = NULL;
for (; sco->next != NULL; sco = sco->next) { ; } //移动到尾节点
sco->next = temp;
sco = temp;
printf("\n录入成功!\n");
_getch();
return 0;
}
/*注销学生*/
int DelStudent(Student *&head)
{
Student *p = head, *q;
q = p->next;
char name[30], id[30];
printf("请输入学生姓名及学号:");
scanf("%s %s", &name, &id);
while (q)
{
if (strcmp(q->Name, name) == 0 && strcmp(q->ID, id) == 0)
{
p->next = q->next;
free(q); //删除p节点
printf("\n删除成功\n");
_getch();
return 0;
}
else
{
p = p->next;
q = q->next;
}
}//while循环结束
return -1;
}
/*注销教职工*/
int DelTeacher(Teacher *&head)
{
Teacher *p = head, *q;
q = p->next;
char name[30], id[30];
printf("\n请输入教职工姓名及职工号:");
scanf("%s %s", name, id);
while (q)
{
if (strcmp(q->Name, name) == 0 && strcmp(q->ID, id) == 0)
{
p->next = q->next;
free(q); //删除p节点
printf("\n删除成功\n");
_getch();
return 0;
}
else
{
p = p->next;
q = q->next;
}
}//while循环结束
return -1;
}
/*删除分数*/
int DelScore(Score *&head)
{
Score *sco1=head,*sco2=head->next;
char name[30], id[30];
printf("请输入学生ID及科目:");
scanf("%s %s", id, name);
while (sco2)
{
if (strcmp(sco2->OID, id) == 0 && strcmp(sco2->Name, name) == 0)
{
sco1->next = sco2->next;
free(sco2);
printf("\n删除成功\n");
_getch();
return 0;
}
else
{
sco1 = sco1->next;
sco2 = sco1->next;
}
}//while循环结束
return -1;
}
/*查找学生*/
int FindStudent(Student *&head)
{
Student *stu = head;
char key[30];
printf("\n请输入关键词");
scanf("%s",&key);
while (stu)
没有合适的资源?快使用搜索试试~ 我知道了~
C语言教学管理系统.zip
共71个文件
tlog:18个
obj:6个
pdb:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 50 浏览量
2022-04-11
12:29:51
上传
评论 2
收藏 61.5MB ZIP 举报
温馨提示
适合课设 包含学生管理,教职工管理,成绩管理。 直接可用,默认账户user,密码123456
资源推荐
资源详情
资源评论
收起资源包目录
C语言教学管理系统.zip (71个子文件)
教学管理系统
.vs
教学管理系统
v16
Browse.VC.db 32.13MB
Solution.VC.db 664KB
.suo 38KB
ipch
AutoPCH
b569403585202840
FUNCTION.ipch 45.94MB
52301c95e90163e1
MAIN.ipch 45.75MB
69932626a4250a19
MAIN.ipch 45.69MB
52269373ed6df7f5
FILE.ipch 45.88MB
教学管理系统.sln 2KB
教学管理系统.VC.db 24.96MB
教学管理系统
infor.dat 32B
function.h 2KB
struct.h 886B
教学管理系统.vcxproj 6KB
student.dat 88B
score.dat 0B
x64
Debug
教学管理系统.tlog
CL.write.1.tlog 2KB
CL.read.1.tlog 89KB
CL.command.1.tlog 2KB
link.write.1.tlog 898B
link.command.1.tlog 2KB
link.read.1.tlog 6KB
教学管理系统.lastbuildstate 192B
vc142.pdb 172KB
main.obj 65KB
教学管理系统.log 27KB
vc142.idb 651KB
function.obj 99KB
main.cpp 10KB
teacher.dat 208B
教学管理系统.vcxproj.filters 1KB
Debug
vc140.pdb 172KB
教学管理系统.tlog
CL.write.1.tlog 1KB
CL.read.1.tlog 41KB
CL.command.1.tlog 1KB
link.write.1.tlog 430B
link.command.1.tlog 1KB
link.read.1.tlog 3KB
教学管理系统.lastbuildstate 206B
main.obj 49KB
vc140.idb 683KB
教学管理系统.log 22KB
function.obj 78KB
教学管理系统.Build.CppClean.log 1020B
教学管理系统.vcxproj.user 165B
function.cpp 16KB
Temp_pre
Temp_pre.vcxproj 6KB
Temp_pre.vcxproj.user 165B
file.cpp 1KB
Temp_pre.vcxproj.filters 1KB
Debug
vc140.pdb 172KB
Temp_pre.tlog
CL.write.1.tlog 1KB
CL.read.1.tlog 40KB
Temp_pre.lastbuildstate 206B
CL.command.1.tlog 1014B
link.write.1.tlog 436B
link.command.1.tlog 2KB
link.read.1.tlog 3KB
vc140.idb 691KB
源.obj 2KB
Temp_pre.log 525B
file.obj 9KB
源.cpp 0B
x64
Debug
教学管理系统.exe 88KB
教学管理系统.ilk 477KB
教学管理系统.pdb 500KB
Debug
Temp_pre.exe 37KB
教学管理系统.exe 56KB
教学管理系统.ilk 354KB
教学管理系统.pdb 500KB
Temp_pre.ilk 285KB
Temp_pre.pdb 596KB
共 71 条
- 1
资源评论
等天晴i
- 粉丝: 3486
- 资源: 10万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- DrawDB 是一个健壮且用户友好的数据库实体关系 (DBER) 编辑器,直接位于您的浏览器中
- PHP库通过返回原始SQL来实现ActiveRecord 用于PHP5.3和NO PDO场景的yii2 ORM移植
- 5152单片机proteus仿真和源码用数组作函数参数控制流水花样
- 2024年全域电商矩阵109节线上课-课程网盘链接提取码下载 .txt
- 对 sqlite 的使用进行简单封装,仅涉及简单的单表 增删改查,基于 FMDB, 操作基于 model
- 5152单片机proteus仿真和源码用函数型指针控制P1口灯花样
- 对Hibernate框架的二次封装,简化对数据库的操作
- 5152单片机proteus仿真和源码用定时器T1查询方式控制单片机发出1KHz音频
- 由 Top10 开发和使用的惯用 Scala Redis 客户端 这是一项正在进行的工作,虽然在生产中使用,但应将其视为在生产中
- SwiftUI - SceanAppDelegate
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功