标签:def 开头 .cpp lse fun ffffff etc get close
在之前的增强版上面改动了一下,难度不大,代码很low,大牛勿喷,准备再改进一下。
#pragma once #ifndef Color_H #define Color_H void color(const unsigned short color1) { if (color1 >= 0 && color1 <= 15) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color1); else SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15); } #endif
#pragma once #ifndef AddStudent_H #define AddStudent_H class AddStudent { private: char Character_A[2]; char Character_a[5]; char SID[5]; char Character_B[2]; char Character_b[6]; char Name[10]; char Character_C[2]; char Character_c[5]; char Age[5]; char Character_D[2]; char Character_d[8]; char Gender[10]; char Character_E[2]; char Character_e[15]; char EntranxeScore[10]; char Character_F[2]; public: AddStudent(); ~AddStudent(); public: void MenuBar();//菜单函数 void QueryFunctionMenu();//查询功能菜单 void MoreFunction();//更多功能函数 void Sort_Num();//按学号排序函数 void TotalScoreRanking();//按总成绩排序函数 void AddStudentInformation();//添加学生信息函数 void DeleteStudentInformation();//删除学生信息函数 void ChangeStudentInformation();//更改学生信息函数 void QueryStudentInformation();//查询学生信息函数 void ShowStudentInformation();//显示所有学生信息函数 void AdditionalFunction();//附加功能选项函数 void QueryStudentID();//通过学号查询函数 void QueryStudentName();//通过学生姓名查询函数 void QueryStudentAge();//通过学生年龄查询函数 void QueryStudentEntranxeScore();//通过学生分数查询函数 void AddStudent_txt();//插入列表函数 void checkName(size_t m, char Name[]);//检查姓名函数 void checkSID(size_t j);//检查学号大小函数 void checkSID_1(size_t m);//检查学号是否重复函数 void checkGender(size_t i, char a[]);//检查性别函数 void checkAge(size_t m);//检查年龄函数 void checkEntranxeScore(size_t k);//检查分数函数 void getName(char name[]);//检查姓名函数 int JudgeDate(size_t n);//检查文本数据 void EnterStudentInformation(size_t i);//输入学生信息 void ExchangeFunction(size_t m, size_t n);////交换数据结构中两个统一结构的不同下标的结构值 }; #endif
#include <iostream> #include <cstdlib> #include <cmath> #include <Windows.h> #include <cstddef> #include "AddStudent.h" #include "Color.h" #define N 750 #pragma warning(disable : 4996) #pragma warning(disable : 4477) using namespace std; int mcount = 0; char LineFeed = ‘\n‘; AddStudent AddStudent_m[N], Open; AddStudent::AddStudent() {} AddStudent::~AddStudent() {} int AddStudent::JudgeDate(size_t n) { if(AddStudent_m[n].Age[0] == ‘\0‘){ return 1; } return 0; } void AddStudent::checkSID(size_t j)//检查学号大小函数 { int num_int; num_int = atoi(AddStudent_m[j].SID); while (num_int <= 0 || num_int > N) { color(4); cout << "warning:SID的取值范围在0~N,请重新输入.\n"; color(15); cout << "请输入学生的学号:"; cin >> AddStudent_m[j].SID; num_int = atoi(AddStudent_m[j].SID); if (num_int > 0 && num_int <= N) { break; } } } void AddStudent::checkSID_1(size_t m)//检查学号是否重复函数 { int k, num_int, num1_int; num1_int = atoi(AddStudent_m[m].SID); loop: for (k = 0; k < mcount; k++) { if (k == m) { continue; } num_int = atoi(AddStudent_m[k].SID); while (num_int == num1_int) { color(4); cout << "学号重复,请重新输入.\n"; color(15); cout << "请输入学号:"; cin >> AddStudent_m[m].SID; num_int = atoi(AddStudent_m[k].SID); goto loop; } } } //因为选择输入的方式是ab+,从新从i=0开始输入进去,所以想要通过 void AddStudent::checkName(size_t m, char Name[])//检查姓名函数 { while (strlen(Name) > 10) { color(4); cout << "Warning:Name的字数最多为5,请重新输入.\n"; color(15); cout << "请输入学生的姓名:"; cin >> AddStudent_m[m].Name; } } void AddStudent::checkGender(size_t i, char a[])//检查性别函数 { while (strcmp(a, "男") && strcmp(a, "女")) { color(4); cout << "Warning:Gender只能是男或女,请重新输入.\n"; color(15); cout << "请输入学生的性别:"; cin >> AddStudent_m[i].Gender; } } void AddStudent::checkAge(size_t m)//检查年龄函数 { int num_int; num_int = atoi(AddStudent_m[m].Age); while (num_int < 0 || num_int>122) { color(4); cout << "Warning:Age的取值范围在0~122,请重新输入,严肃对待!\n"; color(15); cout << "请输入学生的年龄:"; cin >> AddStudent_m[m].Age; num_int = atoi(AddStudent_m[m].Age);//重新赋值变量,检测退出条件 } } void AddStudent::checkEntranxeScore(size_t k) { double num_double; num_double = atof(AddStudent_m[k].EntranxeScore); while (num_double < 0 || num_double>750) { color(4); cout << "Warning:EntranxeScore的取值范围在0~750,请重新输入.\n"; color(15); cout << "请输入学生的分数:"; cin >> AddStudent_m[k].EntranxeScore; num_double = atof(AddStudent_m[k].EntranxeScore); //重新赋值变量,检测退出条件 } } void AddStudent::getName(char name[]) { while (1) { cout << "请输入学生的姓名:"; fflush(stdin); cin >> name; if (strlen(name) < 10) { break; } } } void AddStudent::MenuBar() { system("date /t"); system("TIME /t\n"); cout << " **********欢迎使用学生信息管理系统(当前有" << mcount << "人)********\n"; cout << " *\t\t (1)添加学生信息 \t\t\t*\n"; cout << " *\t\t (2)删除学生信息 \t\t\t*\n"; cout << " *\t\t (3)更改学生信息\t\t\t*\n"; cout << " *\t\t (4)查询学生信息\t\t\t*\n"; cout << " *\t\t (5)显示所有学生信息\t\t\t*\n"; cout << " *\t\t (6)附加功能选项 \t\t\t*\n"; cout << " *\t\t (0)退出学生系统 \t\t\t*\n"; cout << " *\t\t\t\t\t 作者:liu\t*\n"; cout << " *****************************************************\n"; } void AddStudent::QueryFunctionMenu() { system("cls"); system("date /t"); system("TIME /t\n"); printf(" ***********查询学生信息(当前有%d人)*****************\n", mcount); printf(" *\t\t(1)通过学生学号查询 \t\t\t*\n"); printf("\n"); printf(" *\t\t(2)通过学生姓名查询 \t\t\t*\n"); printf("\n"); printf(" *\t\t(3)通过学生年龄查询 \t\t\t*\n"); printf("\n"); printf(" *\t\t(4)通过学生分数查询 \t\t\t*\n"); printf(" *****************************************************\n"); } void AddStudent::MoreFunction() { system("cls"); cout << " *******************附加功能*************\n"; cout << "\t *\t\t\t\t\t *\n"; cout << " *\t\t(1)按学号进行整理 \t *\n"; cout << "\t *\t\t\t\t\t *\n"; cout << " *\t\t(2)按总分进行整理 \t *\n"; cout << "\t *\t\t\t\t\t *\n"; color(3); cout << "\t *\t待开发... ... *\n"; color(15); cout << "\t ****************************************\n"; } void AddStudent::EnterStudentInformation(size_t i) { cout << "请输入学生的学号:"; cin >> AddStudent_m[i].SID; Open.checkSID(i); Open.checkSID_1(i); color(8); cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; color(15); cout << "请输入学生的名字:"; cin >> AddStudent_m[i].Name; Open.checkName(i, AddStudent_m[i].Name); color(8); cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; color(15); cout << "请输入学生的年龄:"; cin >> AddStudent_m[i].Age; Open.checkAge(i); color(8); cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; color(15); cout << "请输入学生的性别:"; cin >> AddStudent_m[i].Gender; Open.checkGender(i, AddStudent_m[i].Gender); color(8); cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; color(15); cout << "请输入学生的总成绩:"; cin >> AddStudent_m[i].EntranxeScore; Open.checkEntranxeScore(i); color(8); printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); color(15); } void AddStudent::AddStudentInformation()//添加学生信息函数 { FILE *fp; int n, m = mcount; if ((fp = fopen("D:\\test_1.txt", "ab+")) == NULL)//检测文本是否正常打开 { color(4); cout << "Can‘t open the file!"; color(15); system("PAUSE"); exit(1); } cout << "请输入您要添加的学生信息人数:"; cin >> n; for (int i = mcount; i < n + m; i++) { cout << "请输入No." << i + 1 << "的信息.\n"; Open.EnterStudentInformation(i - m);//录入学生信息 mcount++; } fwrite(AddStudent_m, sizeof(class AddStudent), n, fp); rewind(fp); color(2); cout << "添加成功!\n"; cout << "学生信息目录已更新.\n"; fread(AddStudent_m, sizeof(class AddStudent), mcount, fp);//读取学生信息 color(15); cout << "___________________________________________________\n"; cout << "| 学号 | 姓名 | 年龄 | 性别 | 总分成绩 |\n"; for (int i = 0; i < mcount; i++)//打印更新的学生信息 { if (AddStudent_m[i].SID > 0) cout << " " << AddStudent_m[i].SID << " " << AddStudent_m[i].Name << " " << AddStudent_m[i].Age << " " << AddStudent_m[i].Gender << "\t " << AddStudent_m[i].EntranxeScore << endl; } cout << "|-------------------------------------------------|\n"; fclose(fp); cout << "按任意键返回主菜单... ....\n"; system("PAUSE"); } void AddStudent::DeleteStudentInformation()//删除学生信息 { FILE *fp; int m, j = 0, num_int; if ((fp = fopen("D:\\test_1.txt", "wb+")) == NULL) { color(4); cout << "Can‘t open the file!\n"; color(15); system("PAUSE"); exit(1); } if (mcount == 0) { color(4); cout << "The file is NULL!!!\n"; color(15); return; } cout << "请输入你要删除的学生的学号:"; cin >> m; fread(AddStudent_m, sizeof(class AddStudent), mcount, fp); for (int k = 0; k < mcount; k++) { num_int = atoi(AddStudent_m[k].SID); if (num_int == m) { cout << "_____________________________________________________\n"; cout << "| 学号 | 姓名 | 年龄 | 性别 | 总分成绩 |\n"; // printf(" %.2d %-6s %-3d %-3s \t%5.2lf \n", AddStudent_m[k].SID, AddStudent_m[k].Name, AddStudent_m[k].Age, AddStudent_m[k].Gender, AddStudent_m[k].EntranxeScore); cout << " " << AddStudent_m[k].SID << " " << AddStudent_m[k].Name << " " << AddStudent_m[k].Age << " " << AddStudent_m[k].Gender << "\t " << AddStudent_m[k].EntranxeScore << endl; cout << "|---------------------------------------------------|\n"; for (int i = k; i < mcount - 1; i++)//将要删除的数后面的函数往前进一格,占去要删除的部分 { strcpy(AddStudent_m[i].SID, AddStudent_m[i + 1].SID); strcpy(AddStudent_m[i].Name, AddStudent_m[i + 1].Name); strcpy(AddStudent_m[i].Age, AddStudent_m[i + 1].Age); strcpy(AddStudent_m[i].Gender, AddStudent_m[i + 1].Gender); strcpy(AddStudent_m[i].EntranxeScore, AddStudent_m[i + 1].EntranxeScore); } mcount--; fwrite(AddStudent_m, sizeof(class AddStudent), mcount, fp); rewind(fp);//使指针回到开头 fclose(fp); color(2); cout << "删除成功!按任意键继续... ...\n"; color(15); j++; } } if (j == 0) { color(4); cout << "查无此人!\n"; color(15); } system("PAUSE"); } void AddStudent::ChangeStudentInformation()//更改学生信息 { FILE *fp; int m, k, j = 0, num_int; if ((fp = fopen("D:\\test_1.txt", "rb+")) == NULL) { cout << "Can‘t open the file!\n"; system("PAUSE"); exit(1); } if (mcount == 0) { color(4); cout << "The file is NULL!!!\n"; color(15); return; } cout << "请输入你要更改的学生的学号:"; cin >> m; fread(AddStudent_m, sizeof(class AddStudent), mcount, fp); for (k = 0; k < mcount; k++) { num_int = atoi(AddStudent_m[k].SID); if (num_int == m) { cout << "_____________________________________________________\n"; cout << "| 学号 | 姓名 | 年龄 | 性别 | 总分成绩 |\n"; cout << " " << AddStudent_m[k].SID << " " << AddStudent_m[k].Name << " " << AddStudent_m[k].Age << " " << AddStudent_m[k].Gender << "\t " << AddStudent_m[k].EntranxeScore << endl; cout << "|---------------------------------------------------|\n"; cout << "请输入你要修改的内容:\n"; EnterStudentInformation(k); rewind(fp); fwrite(AddStudent_m, sizeof(class AddStudent), mcount, fp); fclose(fp); color(2); cout << "更改成功!按任意键继续... ...\n"; color(15); j++; } } if (j == 0) { color(4); cout << "查无此人!\n"; color(15); } system("PAUSE"); } void AddStudent::QueryStudentInformation()//查询学生信息 { int m; Open.QueryFunctionMenu();//进入查询功能菜单 cout << "请输入你查询的方式序列号:"; cin >> m; do { switch (m) { case 1:Open.QueryStudentID(); break; case 2:Open.QueryStudentName(); break; case 3:Open.QueryStudentAge(); break; case 4:Open.QueryStudentEntranxeScore(); break; } } while (m < 1 || m>4); } void AddStudent::ShowStudentInformation()//显示所有学生信息 { FILE *fp; if ((fp = fopen("D:\\test_1.txt", "rb")) == NULL) { color(4); cout << "Can‘t open the file!\n"; color(15); system("PAUSE"); exit(1); } fread(AddStudent_m, sizeof(class AddStudent), mcount, fp); if (mcount == 0) { color(4); cout << "The file is NULL!\n"; color(15); system("PAUSE"); return; } else { cout << "_____________________________________________________\n"; cout << "| 学号 | 姓名 | 年龄 | 性别 | 总分成绩 |\n"; for (int i = 0; i < mcount; i++) { if (AddStudent_m[i].SID != ‘\0‘) cout << " " << AddStudent_m[i].SID << " " << AddStudent_m[i].Name << " " << AddStudent_m[i].Age << " " << AddStudent_m[i].Gender << "\t " << AddStudent_m[i].EntranxeScore << endl; } cout << "|---------------------------------------------------|\n"; } fclose(fp); cout << "按任意键返回主菜单... ...\n"; system("PAUSE"); } void AddStudent::AdditionalFunction()//附加功能选项 { Open.MoreFunction();//附加功能 int k; do { cout << "请输入你要操作的序号:"; scanf("%d", &k); switch (k) { case 1:Open.Sort_Num(); break; case 2:Open.TotalScoreRanking(); break; default: { color(4); cout << "输入有误,请重新输入!\n"; color(15); } } } while (k < 1 || k>2); } void AddStudent::QueryStudentID()//学生学号查询 { FILE *fp; int m, n, j = 0, num_int; cout << "请输入你要搜索的学生学号范围:\n"; cout << "最小值:"; cin >> m; cout << "最大值:"; cin >> n; fp = fopen("D:\\test_1.txt", "rb+"); fread(AddStudent_m, sizeof(class AddStudent), mcount, fp); cout << "_____________________________________________________\n"; cout << "| 学号 | 姓名 | 年龄 | 性别 | 总分成绩 |\n"; for (int i = 0; i < mcount; i++) { num_int = atoi(AddStudent_m[i].SID); if (num_int >= m && num_int <= n) { cout << " " << AddStudent_m[i].SID << " " << AddStudent_m[i].Name << " " << AddStudent_m[i].Age << " " << AddStudent_m[i].Gender << "\t " << AddStudent_m[i].EntranxeScore << endl; cout << "|---------------------------------------------------|\n"; j++; } } if (j == 0) { cout << "无相关学生信息.\n"; } cout << "按任意键返回主菜单... ...\n"; system("PAUSE"); } void AddStudent::QueryStudentName()//学生姓名查询 { FILE *fp; int n = 0; char name[10]; getName(name);//输入学生姓名 fp = fopen("D:\\test_1.txt", "rb+"); fread(AddStudent_m, sizeof(class AddStudent), mcount, fp); for (int i = 0; i < mcount; i++) { if (strcmp(AddStudent_m[i].Name, name) == 0) { cout << "_____________________________________________________\n"; cout << "| 学号 | 姓名 | 年龄 | 性别 | 总分成绩 |\n"; cout << " " << AddStudent_m[i].SID << " " << AddStudent_m[i].Name << " " << AddStudent_m[i].Age << " " << AddStudent_m[i].Gender << "\t " << AddStudent_m[i].EntranxeScore << endl; cout << "|---------------------------------------------------|\n"; ++n; break; } } if (n == 0) { color(4); cout << "无相关学生信息!\n"; color(15); } cout << "按任意键返回主菜单... ...\n"; system("PAUSE"); } void AddStudent::QueryStudentAge()//学生年龄查询 { FILE *fp; int m, n, j = 0, num_int; cout << "请输入你要查询的学生年龄范围:\n"; cout << "最小值:"; cin >> m; cout << "最大值:"; cin >> n; fp = fopen("D:\\test_1.txt", "rb+"); fread(AddStudent_m, sizeof(class AddStudent), mcount, fp); cout << "_____________________________________________________\n"; cout << "| 学号 | 姓名 | 年龄 | 性别 | 总分成绩 |\n"; for (int i = 0; i < mcount; i++) { num_int = atoi(AddStudent_m[i].Age); if (num_int >= m && num_int <= n) { cout << " " << AddStudent_m[i - 1].SID << " " << AddStudent_m[i - 1].Name << " " << AddStudent_m[i - 1].Age << " " << AddStudent_m[i - 1].Gender << "\t " << AddStudent_m[i - 1].EntranxeScore << endl; cout << "|---------------------------------------------------|\n"; j++; } } if (j == 0) { cout << "无相关学生信息!\n"; } cout << "按任意键返回主菜单... ...\n"; system("PAUSE"); } void AddStudent::QueryStudentEntranxeScore()//学生分数查询 { FILE *fp; int m, n, j = 0; double num_double; cout << "请输入你要查询的学生总成绩范围:\n"; cout << "最小值:"; cin >> m; cout << "最大值:"; cin >> n; fp = fopen("D:\\test_1.txt", "rb+"); fread(AddStudent_m, sizeof(class AddStudent), mcount, fp); cout << "_____________________________________________________\n"; cout << "| 学号 | 姓名 | 年龄 | 性别 | 总分成绩 |\n"; for (int i = 0; i < mcount; i++) { num_double = atof(AddStudent_m[i].EntranxeScore); if (num_double >= m && num_double <= n) { cout << " " << AddStudent_m[i].SID << " " << AddStudent_m[i].Name << " " << AddStudent_m[i].Age << " " << AddStudent_m[i].Gender << "\t " << AddStudent_m[i].EntranxeScore << endl; cout << "|---------------------------------------------------|\n"; j++; } } if (j == 0) { cout << "无相关学生信息!\n"; } cout << "按任意键返回主菜单... ...\n"; system("PAUSE"); } void AddStudent::ExchangeFunction(size_t m, size_t n)//交换数据结构中两个统一结构的不同下标的结构值 { double max = 0; int max_1 = 0; strcpy(Open.EntranxeScore, AddStudent_m[m].EntranxeScore); strcpy(AddStudent_m[m].EntranxeScore, AddStudent_m[n].EntranxeScore); strcpy(AddStudent_m[n].EntranxeScore, Open.EntranxeScore); strcpy(Open.Age, AddStudent_m[m].Age); strcpy(AddStudent_m[m].Age, AddStudent_m[n].Age); strcpy(AddStudent_m[n].Age, Open.Age); strcpy(Open.SID, AddStudent_m[m].SID); strcpy(AddStudent_m[m].SID, AddStudent_m[n].SID); strcpy(AddStudent_m[n].SID, Open.SID); strcpy(Open.Gender, AddStudent_m[m].Gender); strcpy(AddStudent_m[m].Gender, AddStudent_m[n].Gender); strcpy(AddStudent_m[n].Gender, Open.Gender); strcpy(Open.Name, AddStudent_m[m].Name); strcpy(AddStudent_m[m].Name, AddStudent_m[n].Name); strcpy(AddStudent_m[n].Name, Open.Name); } void AddStudent::Sort_Num()//按学号查询 { FILE *fp; if ((fp = fopen("D:\\test_1.txt", "rb+")) == NULL) { color(4); cout << "Can‘t open the file!\n"; color(15); system("PAUSE"); exit(1); } int num_int, num1_int; for (int m = 0; m < mcount - 1; m++)//比较学号大小 { for (int n = m + 1; n < mcount; n++) { num_int = atoi(AddStudent_m[n].SID); num1_int = atoi(AddStudent_m[m].SID); if (num_int < num1_int) { Open.ExchangeFunction(m, n);//交换一个结构体整体值 } } } color(6); cout << "排序成功!按任意键继续... ...\n"; color(15); cout << "_____________________________________________________\n"; cout << "| 学号 | 姓名 | 年龄 | 性别 | 总分成绩 |\n"; for (int j = 0; j < mcount; j++) { cout << " " << AddStudent_m[j].SID << " " << AddStudent_m[j].Name << " " << AddStudent_m[j].Age << " " << AddStudent_m[j].Gender << "\t " << AddStudent_m[j].EntranxeScore << endl; cout << "|---------------------------------------------------|\n"; } rewind(fp); fwrite(AddStudent_m, sizeof(class AddStudent), mcount, fp); fclose(fp); system("PAUSE"); } void AddStudent::TotalScoreRanking()//按总分排序 { FILE *fp; if ((fp = fopen("D:\\test_1.txt", "rb+")) == NULL) { color(4); cout << "Can‘t open the file!\n"; color(15); system("PAUSE"); exit(1); } double num_double, num1_double; for (int m = 0; m < mcount - 1; m++)//比较总分大小 { for (int n = m + 1; n < mcount; n++) { num_double = atof(AddStudent_m[n].EntranxeScore); num1_double = atof(AddStudent_m[m].EntranxeScore); if (num_double > num1_double) { ExchangeFunction(m, n);//交换两个结构体整体值 } } } color(6); cout << "排序成功!按任意键继续... ...\n"; color(15); cout << "_____________________________________________________\n"; cout << "| 学号 | 姓名 | 年龄 | 性别 | 总分成绩 |\n"; for (int j = 0; j < mcount; j++) { cout << " " << AddStudent_m[j].SID << " " << AddStudent_m[j].Name << " " << AddStudent_m[j].Age << " " << AddStudent_m[j].Gender << "\t " << AddStudent_m[j].EntranxeScore << endl; cout << "|---------------------------------------------------|\n"; } rewind(fp); fwrite(AddStudent_m, sizeof(class AddStudent), mcount, fp); fclose(fp); system("PAUSE"); } void AddStudent::AddStudent_txt() { for (size_t i = 0; i < N; i++) { strcpy(AddStudent_m[i].Character_A, "\r\n"); strcpy(AddStudent_m[i].Character_B, "\r\n"); strcpy(AddStudent_m[i].Character_C, "\r\n"); strcpy(AddStudent_m[i].Character_D, "\r\n"); strcpy(AddStudent_m[i].Character_E, "\r\n"); strcpy(AddStudent_m[i].Character_F, "\r\n"); strcpy(AddStudent_m[i].Character_a, "SID:"); strcpy(AddStudent_m[i].Character_b, "Name:"); strcpy(AddStudent_m[i].Character_c, "Age:"); strcpy(AddStudent_m[i].Character_d, "Gender:"); strcpy(AddStudent_m[i].Character_e, "EntranxeScore:"); } } int main(void) { int num_1, k; FILE *fp; if ((fp = fopen("D:\\test_1.txt", "ab+")) == NULL) { ;//打开文本/创建,进行操作 color(4); cerr << "Open the file error!" << endl; color(15); system("PAUSE"); exit(1); } fread(AddStudent_m, sizeof(class AddStudent), N, fp);//读取文本储存信息 Open.AddStudent_txt(); for (k = 0; k < N; k++)//判断文本中储存人数(Age==0表示此处无数据) { if (AddStudent_m[k].JudgeDate(k)) { break; } mcount++; } fclose(fp);//关闭指针 Open.MenuBar();//显示菜单 while (1)//使用者操作 { do { cout << "请输入要进行操作的序列号:"; cin >> num_1; } while (num_1 < 0 || num_1>6); if (num_1 == 0)break; switch (num_1) { case 1:Open.AddStudentInformation(); break; case 2:Open.DeleteStudentInformation(); break; case 3:Open.ChangeStudentInformation(); break; case 4:Open.QueryStudentInformation(); break; case 5:Open.ShowStudentInformation(); break; case 6:Open.AdditionalFunction(); break; } system("cls"); Open.MenuBar(); } return 0; }
我存放的盘为D盘test_1.txt文件,如果显示Open the file error! 可以查看自己是否有D盘,可以自行更改到C盘。
主要功能:
附加机制:
标签:def 开头 .cpp lse fun ffffff etc get close
原文地址:https://www.cnblogs.com/Mayfly-nymph/p/9224538.html