日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無(wú)先后,達(dá)者為師

網(wǎng)站首頁(yè) 編程語(yǔ)言 正文

C語(yǔ)言實(shí)現(xiàn)教務(wù)管理系統(tǒng)_C 語(yǔ)言

作者:「已注銷」 ? 更新時(shí)間: 2022-05-20 編程語(yǔ)言

本文實(shí)例為大家分享了C語(yǔ)言實(shí)現(xiàn)教務(wù)管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

目前已完成教師管理系統(tǒng)部分,學(xué)生管理系統(tǒng)待完成:

實(shí)現(xiàn)效果如圖:

主界面:

教師端——注冊(cè)賬號(hào)

進(jìn)入教師管理系統(tǒng)

文件的保存

代碼如下:

#include
#include
#include
/*教師應(yīng)用結(jié)構(gòu)體*/
typedef struct Teacher
{
?? ?char name[10];//學(xué)生姓名
?? ?char iD[10];//學(xué)生學(xué)號(hào)
?? ?float score;//學(xué)生成績(jī)
}teacher;
/*教師鏈表結(jié)點(diǎn)*/
typedef struct
{
?? ?teacher data;
?? ?struct Teacher* next;
}Tutor;
/*教師系統(tǒng)賬號(hào)*/
typedef struct manager
{
?? ?char manAcc[10];?? ?//賬號(hào)
?? ?char manPassw[10];?? ?//密碼
?? ?struct manager* next;
}Manager;
Manager* managerHead;

/*函數(shù)聲明*/
void mainMenu();//主菜單
void studentPort();//學(xué)生端
/*---------------------------------------------------------*/
/* ? ? ? ? ? ? ? ? 教師管理系統(tǒng)函數(shù) ? ? ? ? ? ? ? ? ? ? ? */
/*---------------------------------------------------------*/
void showTeacherPort();//教師端
void teacherRegister();//教師端賬號(hào)注冊(cè)
void teacherLogin();//教師端登錄
int Password_Text_Find();//密碼驗(yàn)證
Manager* Manager_check();//賬號(hào)核對(duì)
void teacherPort();//教師端
void tutorMenu();//教師管理菜單
void teacherFunction();//教師端功能應(yīng)用
void insertStudentData();//學(xué)生信息錄入
void showStudentData();//學(xué)生信息展示
void searchStudentData();//學(xué)生信息查詢
void changeStudentData();//學(xué)生信息修改
Tutor* deleteStudentData();//學(xué)生信息刪除

/*---------------------------------------------------------*/
/* ? ? ? ? ? ? ? ? 教師鏈表的初始化 ? ? ? ? ? ? ? ? ? ? ? ?*/
/*---------------------------------------------------------*/
Tutor* initTeacherList();//鏈表初始化
Tutor* createNode();//創(chuàng)建結(jié)點(diǎn)

/*---------------------------------------------------------*/
/* ? ? ? ? ? ? ? ? 文件的讀寫操作 ? ? ? ? ? ? ? ? ? ? ? ? ?*/
/*---------------------------------------------------------*/
void readInfoFromFile();
void writeInfoToFile();


int main(void)
{?? ?

?? ?int choice = 0;
?? ?while (1)
?? ?{
?? ??? ?mainMenu();//主菜單
?? ??? ?printf("\t請(qǐng)輸入選擇:");
?? ??? ?scanf("%d", &choice);
?? ??? ?switch (choice)
?? ??? ?{
?? ??? ?case 1:
?? ??? ??? ?teacherPort();
?? ??? ??? ?break;
?? ??? ?case 2:
?? ??? ??? ?studentPort();
?? ??? ??? ?break;
?? ??? ?case 3:
?? ??? ??? ?printf("您已退出系統(tǒng)!\n");
?? ??? ??? ?system("pause");
?? ??? ??? ?exit(0);
?? ??? ?default:
?? ??? ??? ?printf("您的輸入有誤,請(qǐng)重新輸入!\n");
?? ??? ??? ?break;
?? ??? ?}
?? ??? ?system("pause");
?? ??? ?system("cls");
?? ?}
}
/*主菜單*/
void mainMenu()
{
?? ?system("color f0");
?? ?printf("-------------------------------------------------\n");
?? ?printf("*歡迎使用教務(wù)管理系統(tǒng)*\n");
?? ?printf("\t1.教師端\n");
?? ?printf("\t2.學(xué)生端\n");
?? ?printf("\t3.退出系統(tǒng)\n");
?? ?printf("-------------------------------------------------\n");
}
/*學(xué)生端*/
void studentPort()
{
?? ?system("cls");
?? ?system("color b0");
?? ?printf("\n\n\n\n\n\n\n\t\t\t\t學(xué)生端暫時(shí)未寫,有興趣可以接著寫?。?!\n\n\n\n\n\n\n\n");
}
/*教師端*/
void showTeacherPort()
{
?? ?system("CLS");
?? ?printf("\n\n\n\t\t\t\t 教師端");
?? ?printf("\n\t\t\t---------------------------------\n\n");
?? ?printf("\t\t\t\t1)注冊(cè)\n");
?? ?printf("\t\t\t\t2)登錄\n");
?? ?printf("\t\t\t\t0)返回\n");
?? ?printf("\n\t\t\t---------------------------------\n\n");
}
/*教師管理菜單*/
void tutorMenu()
{
?? ?system("cls");
?? ?system("color 70");
?? ?printf("-------------------------------------------------\n");
?? ?printf("*歡迎進(jìn)入教師端*\n");
?? ?printf("\t1.學(xué)生信息錄入\n");
?? ?printf("\t2.學(xué)生信息展示\n");
?? ?printf("\t3.學(xué)生信息查詢\n");
?? ?printf("\t4.學(xué)生信息修改\n");
?? ?printf("\t5.學(xué)生信息刪除\n");
?? ?printf("\t6.學(xué)生數(shù)據(jù)保存\n");
?? ?printf("\t0.返回主菜單\n");
?? ?printf("-------------------------------------------------\n");
}
/*教師端賬號(hào)注冊(cè)*/
void teacherRegister()
{
?? ?Manager* p = (Manager*)malloc(sizeof(Manager));
?? ?p->next = NULL;
?? ?printf("請(qǐng)輸入注冊(cè)賬號(hào):");
?? ?scanf("%s", p->manAcc);
?? ?printf("請(qǐng)輸入賬號(hào)密碼:");
?? ?scanf("%s", p->manPassw);
?? ?
?? ?if (managerHead == NULL)
?? ?{
?? ??? ?managerHead = p;
?? ?}
?? ?else
?? ?{
?? ??? ?p->next = managerHead;
?? ??? ?managerHead = p;
?? ?}
?? ?printf("注冊(cè)成功!\n");
}
/*核對(duì)賬號(hào)*/
Manager* Manager_check(char* Manager_num)
{
?? ?Manager* t = managerHead;
?? ?while (t)?
?? ?{
?? ??? ?if (strcmp(Manager_num, t->manAcc) != 0)
?? ??? ?{
?? ??? ??? ?t = t->next;
?? ??? ??? ?continue;
?? ??? ?}
?? ??? ?return t;
?? ?}
?? ?return t;
}
/*密碼驗(yàn)證*/
int Password_Text_Find(char* Password)
{
?? ?char password_tem[20]="";
?? ?int tem = 0;
?? ?int n = 0; ? ?//檢測(cè)輸入次數(shù)
?? ?while (n != 3)?
?? ?{
?? ??? ?scanf("%s", password_tem);
?? ??? ?if (strcmp(password_tem, Password) == 0) {
?? ??? ??? ?tem = 1;
?? ??? ??? ?break;
?? ??? ?}
?? ??? ?else?
?? ??? ?{
?? ??? ??? ?n++;
?? ??? ??? ?printf("\n\t\t輸入錯(cuò)誤,請(qǐng)重新輸入,你還有%d次機(jī)會(huì):", 3 - n);
?? ??? ?}
?? ?}
?? ?return tem;
}
/*教師端登錄*/
void teacherLogin()
{
?? ?char ID[10];
?? ?Manager* t;
?? ?printf("請(qǐng)輸入賬號(hào):");
?? ?scanf("%s",ID);
?? ?t = Manager_check(ID);
?? ?if (!t)
?? ?{
?? ??? ?printf("\t\t抱歉,賬號(hào)不存在\n");
?? ??? ?system("pause");
?? ??? ?return;
?? ?}
?? ?printf("請(qǐng)輸入密碼:");
?? ?if (Password_Text_Find(t->manPassw) == 0)
?? ?{
?? ??? ?printf("\n\t\t已經(jīng)錯(cuò)誤輸入密碼三次,將退出登錄系統(tǒng)···\n");
?? ??? ?system("pause");
?? ??? ?return;
?? ?}?? ?
?? ?printf("\t\t登錄成功···\n");
?? ?system("pause");
?? ?teacherFunction();
}
/*教師端*/
void teacherPort()
{
?? ?while (1)
?? ?{
?? ??? ?showTeacherPort();
?? ??? ?char ch = getch();
?? ??? ?switch(ch)
?? ??? ?{
?? ??? ?case '1':
?? ??? ??? ?teacherRegister();
?? ??? ??? ?break;
?? ??? ?case '2':
?? ??? ??? ?teacherLogin();
?? ??? ??? ?break;
?? ??? ?case '0':
?? ??? ??? ?return;
?? ??? ?default:
?? ??? ??? ?printf("\t\t輸入錯(cuò)誤,請(qǐng)重新輸入\n");
?? ??? ??? ?break;
?? ??? ?}
?? ??? ?system("pause");
?? ??? ?system("cls");
?? ?}
}
/*教師端應(yīng)用功能*/
void teacherFunction()
{
?? ?Tutor* T = initTeacherList();
?? ?teacher data;
?? ?int choice = 0;
?? ?readInfoFromFile(T);
?? ?while (1)
?? ?{
?? ??? ?tutorMenu();//教師菜單
?? ??? ?printf("\t請(qǐng)輸入選擇:");
?? ??? ?scanf("%d", &choice);
?? ??? ?switch (choice)
?? ??? ?{
?? ??? ?case 1:
?? ??? ??? ?printf("\t1.學(xué)生信息錄入\n");
?? ??? ??? ?printf("學(xué)生姓名:");
?? ??? ??? ?scanf("%s", data.name);
?? ??? ??? ?printf("學(xué)生學(xué)號(hào):");
?? ??? ??? ?scanf("%s", data.iD);
?? ??? ??? ?printf("學(xué)生成績(jī):");
?? ??? ??? ?scanf("%f", &data.score);
?? ??? ??? ?insertStudentData(T, data);//錄入學(xué)生信息?? ??? ??? ?
?? ??? ??? ?break;
?? ??? ?case 2:
?? ??? ??? ?showStudentData(T);
?? ??? ??? ?break;
?? ??? ?case 3:
?? ??? ??? ?searchStudentData(T);
?? ??? ??? ?break;
?? ??? ?case 4:
?? ??? ??? ?changeStudentData(T);
?? ??? ??? ?break;
?? ??? ?case 5:?? ??? ??? ?
?? ??? ??? ?T=deleteStudentData(T);
?? ??? ??? ?break;
?? ??? ?case 6:
?? ??? ??? ?writeInfoToFile(T);
?? ??? ??? ?break;
?? ??? ?case 0:
?? ??? ??? ?return;
?? ??? ?default:
?? ??? ??? ?printf("您的輸入有誤,請(qǐng)重新輸入!\n");
?? ??? ??? ?break;
?? ??? ?}
?? ??? ?system("pause");
?? ??? ?system("cls");
?? ?
?? ?}
}
/*教師鏈表初始化*/
Tutor* initTeacherList()
{
?? ?Tutor* headNode = (Tutor*)malloc(sizeof(Tutor));
?? ?headNode->next = NULL;
?? ?return headNode;
}
/*創(chuàng)建結(jié)點(diǎn)*/
Tutor* createNode(teacher data)
{
?? ?Tutor* newNode = (Tutor*)malloc(sizeof(Tutor));
?? ?newNode->data = data;
?? ?newNode->next = NULL;
?? ?return newNode;
}
/*學(xué)生信息錄入*/
void insertStudentData(Tutor* headNode,teacher data)
{
?? ?Tutor* newNode = createNode(data);
?? ?/*頭接法*/
?? ?newNode->next = headNode->next;
?? ?headNode->next = newNode;
?? ?printf("\t錄入成功!\n");
}
/*學(xué)生信息展示*/
void showStudentData(Tutor* headNode)
{
?? ?Tutor* P = headNode->next;
?? ?printf("姓名\t學(xué)號(hào)\t成績(jī)\t\n");
?? ?while (P)
?? ?{
?? ??? ?printf("%s\t%s\t%f\n", P->data.name, P->data.iD, P->data.score);
?? ??? ?P = P->next;
?? ?}
}
/*學(xué)生信息查詢-按學(xué)號(hào)*/
void searchStudentData(Tutor* headNode)
{
?? ?Tutor* P = headNode->next;
?? ?char ID[10] = " ";

?? ?printf("請(qǐng)輸入查找的學(xué)生學(xué)號(hào):");
?? ?scanf("%s", ID);

?? ?while (P)
?? ?{
?? ??? ?if (strcmp(P->data.iD, ID) != 0)
?? ??? ?{
?? ??? ??? ?P = P->next;
?? ??? ??? ?continue;
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?printf("姓名\t學(xué)號(hào)\t成績(jī)\n");
?? ??? ??? ?printf("%s\t%s\t%f\n", P->data.name, P->data.iD, P->data.score);
?? ??? ??? ?return;
?? ??? ?}
?? ?}
?? ?printf("\t目前不存在該學(xué)生信息!\n");
?? ?return;
}
/*學(xué)生信息修改*/
void changeStudentData(Tutor* headNode)
{
?? ?Tutor* P = headNode->next;
?? ?char ID[10] = " ";

?? ?printf("請(qǐng)輸入修改的學(xué)生學(xué)號(hào):");
?? ?scanf("%s", ID);

?? ?while (P)
?? ?{
?? ??? ?if (strcmp(P->data.iD, ID) != 0)
?? ??? ?{
?? ??? ??? ?P = P->next;
?? ??? ??? ?continue;
?? ??? ?}
?? ??? ?else
?? ??? ?{?? ??? ?
?? ??? ??? ?printf("\t請(qǐng)進(jìn)行修改\n");
?? ??? ??? ?printf("學(xué)生姓名:");
?? ??? ??? ?scanf("%s", P->data.name);
?? ??? ??? ?printf("學(xué)生學(xué)號(hào):");
?? ??? ??? ?scanf("%s", P->data.iD);
?? ??? ??? ?printf("學(xué)生成績(jī):");
?? ??? ??? ?scanf("%f", &P->data.score);
?? ??? ??? ?printf("已完成修改!\n");
?? ??? ??? ?return;
?? ??? ?}
?? ?}
?? ?printf("\t目前不存在該學(xué)生信息!\n");
?? ?return;
}
/*學(xué)生信息刪除*/
Tutor* deleteStudentData(Tutor* headNode)
{
?? ?Tutor* head= headNode;
?? ?Tutor* node= head->next;
?? ?char ID[10] = " ";
?? ?
?? ?if (headNode->next == NULL)
?? ?{
?? ??? ?printf("\t當(dāng)前數(shù)據(jù)為空!\n");
?? ??? ?return headNode;
?? ?}?? ?
?? ?printf("請(qǐng)輸入要?jiǎng)h除的學(xué)生學(xué)號(hào):");
?? ?scanf("%s", ID);
?? ?while (node!=NULL)
?? ?{
?? ??? ?if (strcmp(node->data.iD, ID) != 0)
?? ??? ?{
?? ??? ??? ?head = node;
?? ??? ??? ?node = node->next;
?? ??? ??? ?continue;
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?head->next = node->next;
?? ??? ??? ?free(node);
?? ??? ??? ?printf("\t刪除成功!\n");
?? ??? ??? ?return headNode;
?? ??? ?}
?? ?}

?? ?printf("\t未找到該學(xué)生的相關(guān)信息!\n");
?? ?return headNode;
}
//文件讀操作
void readInfoFromFile(Tutor* headNode)
{
?? ?FILE* fp;
?? ?struct Teacher data;
?? ?fp = fopen("1.txt", "r");
?? ?if (fp == NULL)
?? ?{
?? ??? ?fp = fopen("1.txt", "w+");
?? ?}

?? ?//2.讀文件
?? ?fscanf(fp, "姓名\t學(xué)號(hào)\t成績(jī)\n");//fscanf--格式化讀取數(shù)據(jù)
?? ?while (fscanf(fp, "%s\t%s\t%f\n", data.name, data.iD, &data.score) != EOF)
?? ?{
?? ??? ?insertStudentData(headNode, data);
?? ?}
?? ?fclose(fp);
}
//文件寫操作
void writeInfoToFile(Tutor* headNode)
{
?? ?FILE* fp;
?? ?fp = fopen("1.txt", "w");
?? ?Tutor* pMove = headNode->next;
?? ?fprintf(fp, "姓名\t學(xué)號(hào)\t成績(jī)\n"); //fprintf--寫入格式化數(shù)據(jù)
?? ?while (pMove)
?? ?{
?? ??? ?fprintf(fp, "%s\t%s\t%f\n", ?pMove->data.name,pMove->data.iD, pMove->data.score);
?? ??? ?pMove = pMove->next;
?? ?}

?? ?fclose(fp);
}

原文鏈接:https://blog.csdn.net/weixin_53391957/article/details/118886015

欄目分類
最近更新