#include <graphics.h> //调用图形库头文件
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include<string>
#include<fstream>
#include <windows.h>
#include"cstring"
#include<iomanip>
#include"ctime"
#include"fstream"
#include "conio.h"
#include"stdlib.h"
using namespace std;
#define SIZE 100//最大用户容量
int scount = 0;//用作储存当前已注册用户数
void studentlock(){
FILE *read;
FILE *write;
char start[100] = "E:\\程序设计\\学生信息2.txt";
char after[100] = "E:\\程序设计\\学生加密信息.txt";
read = fopen(start, "r");
write = fopen(after, "w");
if (read == NULL || write == NULL)
{
cout << "文件错误";
return;
}
while (!feof(read)){//当条件不是文件尾时执行后续代码
char ch = fgetc(read);//以字符方式读取文件
ch = ch + 3;
fputc(ch, write);//写入文件
}
fclose(write);
fclose(read);
cout << "加密成功";
}
void studentunlock(){
FILE *read;
FILE *write;
char start[100] = "E:\\程序设计\\学生加密信息.txt";
char after[100] = "E:\\程序设计\\学生解密信息.txt";//加密后
read = fopen(start, "r");
write = fopen(after, "w");
if (read == NULL || write == NULL){
cout << "解密失败!!";
return;
}
while (!feof(read)){
char ch = fgetc(read);
ch = ch - 3;
fputc(ch, write);
}
fclose(write);
fclose(read);
cout << "解密成功";
}
//老师加解密
void teacherlock(){
FILE *read;
FILE *write;
char start[100] = "E:\\程序设计\\教师.txt";
char after[100] = "E:\\程序设计\\教师加密信息.txt";
read = fopen(start, "r");
write = fopen(after, "w");
if (read == NULL || write == NULL)
{
cout << "文件错误";
return;
}
while (!feof(read)){
char ch = fgetc(read);
ch = ch + 3;
fputc(ch, write);
}
fclose(write);
fclose(read);
cout << "加密成功";
}
void teacherunlock(){
FILE *read;
FILE *write;
char start[100] = "E:\\程序设计\\教师加密信息.txt";
char after[100] = "E:\\程序设计\\教师解密信息.txt";//加密后
read = fopen(start, "r");
write = fopen(after, "w");
if (read == NULL || write == NULL){
cout << "解密失败!!";
return;
}
while (!feof(read)){
char ch = fgetc(read);
ch = ch - 3;
fputc(ch, write);
}
fclose(write);
fclose(read);
cout << "解密成功";
}
//管理员加解密
void userlock(){
FILE *read;
FILE *write;
char start[100] = "E:\\程序设计\\user.txt";
char after[100] = "E:\\程序设计\\user加密信息.txt";
read = fopen(start, "r");
write = fopen(after, "w");
if (read == NULL || write == NULL)
{
cout << "文件错误";
return;
}
while (!feof(read)){
char ch = fgetc(read);
ch = ch + 3;
fputc(ch, write);
}
fclose(write);
fclose(read);
cout << "加密成功";
}
void userunlock(){
FILE *read;
FILE *write;
char start[100] = "E:\\程序设计\\user加密信息.txt";
char after[100] = "E:\\程序设计\\user解密信息.txt";//加密后
read = fopen(start, "r");
write = fopen(after, "w");
if (read == NULL || write == NULL){
cout << "解密失败!!";
return;
}
while (!feof(read)){
char ch = fgetc(read);
ch = ch - 3;
fputc(ch, write);
}
fclose(write);
fclose(read);
cout << "解密成功";
}
void record(){
ofstream out("information.txt");
time_t timep; //time_t 长整型
time(&timep); //获得time_t结构的时间(UTC时间)
struct tm *p; //tm结构体用于获取日期
p = gmtime(&timep); //转换为struct tm结构的UTC时间
out << "**********" << endl << endl;
out << "----------" << endl << endl;
out << "进入该系统进行操作的时间为:" << endl << "\t\t\t" << 8 + p->tm_hour << "时" << p->tm_min << "分" << "\t"; //小时与北京时间相差8小时
out << 1900 + p->tm_year << "年" << 1 + p->tm_mon << "月" << p->tm_mday << "日" << endl;//tm结构体中实际年份需要加1900,月份从从0开始
out << "**********" << endl << endl;
out << "---------" << endl << endl;
cout << "记录成功!" << endl;
}
void start(){//初始页面
cout << endl;
cout << "\t★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n" << endl;
cout << "\t★\t\t\t*****************************************************\t\t\t\t★\n\n" << endl;
cout << "\t★\t\t\t\t\t 学生 成 绩 管 理 系统\t\t\t\t\t\t★\n\n" << endl;
cout << "\t★\t\t\t \t\t\t\t★\n\n" << endl;
cout << "\t★\t\t\t*****************************************************\t\t\t\t★\n\n" << endl;
cout << "\t★\t\t\t 欢迎使用学生管理系统,祝您使用愉快! \t\t\t\t★\n\n" << endl;
cout << "\t★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n" << endl;
}
int mima(char code[]){ //登陆密码
int x = 0;
char password[20];
//int a;
cout << "\t\t\t【系统提示】请输入密码:";
int i = 4, key = 0;
char c = 0;
while (x < 6 && c != 13)
{
c = getch();
if (c != 13) putchar('*');
password[x++] = c;
}
password[x] = '\0';
while (1)
{
if (strcmp(password, code) != 0)
{
fflush(stdin);//刷新标准输入缓冲区,把输入缓冲区里东西扔掉
cout << endl;
cout << "\t\t\t【系统提示】输入密码有误,您还有" << i-- << "次机会,请重新输入:";
if (i == -1)
{
system("pause");
exit(0);//退出循环
}
}
else key = 1;
x = 0;
while (x < 6 && c != 13)
{
c = getch();
if (c != 13)
putchar('*');
password[x++] = c;
}
password[x] = '\0';
if (key == 1)
break;
}
cout << endl;
cout << "\t\t\t【系统提示】密码输入正确!!欢迎使用本系统!!" << endl;
Sleep(1000);
return key;
}
void showmenu()//学生系统的菜单
{
time_t timep; //time_t 长整型
time(&timep); //获得time_t结构的时间(UTC时间)
struct tm *p_1; //tm结构体用于获取日期
p_1 = gmtime(&timep); //转换为struct tm结构的UTC时间
cout << "\n\n\n" << endl;
cout << "\t\t\t\t\t\t 当前时间为:" << 8 + p_1->tm_hour << "时" << p_1->tm_min << "分" << endl;
cout << "\t\t\t\t\t\t " << 1900 + p_1->tm_year << "年" << 1 + p_1->tm_mon << "月" << p_1->tm_mday << "日" << endl;
cout << "\n" << endl;
cout << "\t\t★————————————————————————————————————————★\n\n" << endl;
cout << "\t\t\t | 1. 学生信息录入\t\t2.学生信息查询\t\t3. 修改学生信息 |\n\n" << endl;
cout << "\t\t\t | 0. 保存信息并退出系统 \t\t\t |\n\n" << endl;
cout << "\t\t★————————————————————————————————————————★\n" << endl;
}
class teacher {
public:
teacher *te;
int Size;
char Name[20];//姓名
char academy[21];// 学院
char mi[10]; //密码
void inputinfo()//从文件中读取数据
{
ifstream fp;
int len;//教师的人数
len = 3;
Size = len;
te = new teacher[Size];
fp.open("E:\\程序设计\\教师.txt");
for (int i = 0; i<len; i++)
{
fp >> te[i].Name >> te[i].academy >> te[i].mi;
}
}
int findjs(){ //确认教师身份
string name;
int p = 1;
//int w;
cout << "\t\t\t【系统提示】请输入教师姓名:";
cin >> name;
int i = 0;
for (; i<Size; i++){
if (te[i].Name == name&&p == mima(te[i].mi)) {
cout << "\t\t\t【系统提示】已确认教师身份,欢迎使用该系统" << endl; return 1;
}
}
if (i >= Size) return 0;
}
};
class User//管理者的类
{
private:
string phone;//电话
string password;//密码
public:
User() {};
void Registers();//注册
void Login();//登录
void save();//保存
void read();//读取
}
us;
User user[SIZE];//user的范围
//保存
void User::save()
{
ofstream ofile;
ofile.open("user.txt", ios::out);
for (int i = 0; i < scount; i++)
{
ofile << user[i].phone << endl;
ofile << user[i].password << endl;
}
ofile.close();
}
//读取
void User::read()
{
ifstream ifile;
ifile.open("user.txt", ios::in);
scount = 0;
if (!ifile.is_open())//判断文件是否能打开
{
return;
}
for (int i = 0; !ifile.eof(); i++)
{
ifile >> user[i].phone;
ifile >> user[i].password;
scount++;
}
scount--;
ifile.close();
}
//注册
void User::Registers()
{
us.read();//读取已储存用户数据
string ph;//电话
string pw1;//密码1
string pw2;//密码2
string school;//学校
for (int i = scount; i < SIZE; i++)
{
here:
cout << "\t\t\t【系统提示】请输入手机号:";
cin >> ph;
//判断新输入的用户信息是否已存在(如果已存在则重新输入)
cout << "请输入所在学校:";
cin >> school;
if (school != "山西师范大学") { cout << "不是本校人员"; exit(0); }
for (int j = 0; j < scount; j++)
{
if (ph == user[j].phone)
{
cout << "\t\t\t【系统提示】用户已存在!" << endl;
goto here;
}
}
user[i].phone = ph;
int chose = -1;
cout << endl;
cout << "\t\t\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n";
cout << "\t\t\t┃ 1.显示密码 2.隐藏密码 ┃\t\n";
cout << "\t\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n";
cout << "\t\t\t【系统提示】请输入你的选择:";
cin >> chose;
if (chose > 2 || chose < -1)
{
cout << "\t\t\t【系统提示】输入格式错误,请重新输入:";
cin >> chose;
}
string pword;
char ch, passwords0[20];
int x = 0;
string pword1;
char ch1, passwords1[20];
int x1 = 0;
switch (chose)
{
case 1:
cout << "\t\t\t【系统提示】请输入密码:";
cin >> pword;
user[i].password = pword;
cout << "\t\t\t【系统提示】请再次密码:";
cin >> pword1;
if (pword1 != user[i].password)
{
cout << "\t\t\t【系统提示】密码不一致!" << endl;
goto here;
}
else
{
scount++;//已注册用户加1
cout << "\t\t\t【系统提示】注册成功!" << endl;
us.save();//保存用户数据
}
break;
case 2:
cout << "\t\t\t【系统提示】请输入密码:";
while ((ch = _getch()) != '\r' && x <= 20)
{
if (ch == '\b')
{
if (x > 0)
{
x--;
cout << "\b \b";//密码支持退格的实现
}
else
putchar(7);
}
else
{
passwords0[x++] = ch;
printf("*");
}
}
passwords0[x] = '\0';
cout << endl;
user[i].password = passwords0;
cout << "\t\t\t【系统提示】请再次密码:";
while ((ch1 = _getch()) != '\r' && x1 <= 20)
{
if (ch1 == '\b')
{
if (x1 > 0)
{
x1--;
cout << "\b \b";//密码支持退格的实现
}
else
putchar(7);
}
else
{
passwords1[x1++] = ch1;
printf("*");
}
}
passwords1[x1] = '\0';
cout << endl;
//比较两次输入的密码是否统一(如果不统一则重新输入)
if (passwords1 != user[i].password)
{
cout << "\t\t\t【系统提示】密码不一致!" << endl;
goto here;
}
else
{
scount++;//已注册用户加1
cout << "\t\t\t【系统提示】注册成功!" << endl;
us.save();//保存用户数据
}
break;
}
char choice;
cout << "\t\t\t【系统提示】是否继续注册(Y/N)? :";
while (1)
{
cin >> choice;
if (choice == 'y' || choice == 'Y' || choice == 'n' || choice == 'N')
break;
else
cout << "\t\t\t【系统提示】输入格式错误,请重新输入: ";
}
if (choice == 'n' || choice == 'N')
{
break;
}
}
}
//登录
void User::Login()
{
us.read();//读取已储存用户数据
string ph;//电话
string pw;//密码
int time = 0;//统计比较次数
here:
cout << "\t\t\t【系统提示】请输入手机号:";
cin >> ph;
int chose = -1;
cout << endl;
cout << "\t\t\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n";
cout << "\t\t\t┃ 1.显示密码 2.隐藏密码 ┃\t\n";
cout << "\t\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n";
cout << "\t\t\t【系统提示】请输入你的选择:";
cin >> chose;
if (chose > 2 || chose < -1)
{
cout << "\t\t\t【系统提示】输入格式错误,请重新输入:";
cin >> chose;
}
string pword;
char ch, passwords0[20];
int x = 0;
switch (chose)
{
case 1:
cout << "\t\t\t【系统提示】请输入密码:";
cin >> pword;
for (int i = 0; i < scount; i++)
{
if (ph == user[i].phone && pword == user[i].password)
{
time++;
cout << "\t\t\t【系统提示】登录成功!" << endl;
}
}
if (time == 0)
{
cout << "\t\t\t【系统提示】手机号或密码错误!" << endl;
goto here;
}
break;
case 2:
cout << "\t\t\t【系统提示】请输入密码:";
while ((ch = _getch()) != '\r' && x <= 20)
{
if (ch == '\b')
{
if (x > 0)
{
x--;
cout << "\b \b";//密码支持退格的实现
}
else
putchar(7);
}
else
{
passwords0[x++] = ch;
printf("*");
}
}
passwords0[x] = '\0';
cout << endl;
//依次比较已储存信息,比较是否匹配(如不匹配则提示错误)
for (int i = 0; i < scount; i++)
{
if (ph == user[i].phone && passwords0 == user[i].password)
{
time++;
cout << "\t\t\t【系统提示】登录成功!" << endl;
}
}
if (time == 0)
{
cout << "\t\t\t【系统提示】手机号或密码错误!" << endl;
goto here;
}
break;
}
}
class student {
public:
student *Stu;
int Size;
string mayjor;//专业
char classid[3];
char idphone[19]; //学号
char Name[20]; //姓名
char Birthday[10]; //生日
int age;//年龄
char homead[50];//家庭住址
string academy;// 学院
string sex;//性别
char telephone[15];//手机号
char number[20];//身份证号
int major;//专业成绩
int math;//数学成绩
int english;//英语成绩
int sumcj;//成绩总数
int rank;//排名
char mi[10];
void inputinfo()//从文件中读取数据
{
ifstream fp;
int len;//学生的人数
len = 10;
Size = len;
Stu = new student[Size];
fp.open("E:\\程序设计\\学生信息2.txt");
for (int i = 0; i<len; i++)
{
fp >> Stu[i].mayjor >> Stu[i].classid >> Stu[i].idphone >> Stu[i].Name;
fp >> Stu[i].Birthday >> Stu[i].age >> Stu[i].homead >> Stu[i].academy >> Stu[i].sex >> Stu[i].telephone >> Stu[i].number;
fp >> Stu[i].major >> Stu[i].math >> Stu[i].english >> Stu[i].mi;
}
}
void inputinformation()//从文件中读取数据
{
ifstream fp;
int len;//学生的人数
cout << "请输入学生的人数:";
cin >> len;
Size = len;
Stu = new student[Size];
fp.open("E:\\程序设计\\学生信息2.txt");
for (int i = 0; i<len; i++)
{
fp >> Stu[i].mayjor >> Stu[i].classid >> Stu[i].idphone >> Stu[i].Name;
fp >> Stu[i].Birthday >> Stu[i].age >> Stu[i].homead >> Stu[i].academy >> Stu[i].sex >> Stu[i].telephone >> Stu[i].number;
fp >> Stu[i].major >> Stu[i].math >> Stu[i].english;
}
cout << "添加学生成功,请按任意键返回" << endl;
for (int i = 0; i<len; i++){
cout << Stu[i].mayjor << '\t' << Stu[i].classid << '\t' << Stu[i].idphone << '\t' << Stu[i].Name << Stu[i].Birthday << '\t' << Stu[i].age << '\t' << Stu[i].homead << '\t';
cout << Stu[i].academy << '\t' << Stu[i].telephone << '\t' << Stu[i].number << '\t' << Stu[i].major << '\t' << Stu[i].math << '\t' << Stu[i].english << endl;;
}
}
void lr()//补充文件中未录入学生信息
{
cout << "输入几位学生的个人基本信息:" << endl;
ofstream ofile;
int len;//学生的人数
cin >> len;
Size += len;
ofile.open("E:\\程序设计\\学生信息2.txt", ios::app);
int i;
for (i = 0; i < len; i++)
{
cout << "----第" << i + 1 << "个学生----" << endl;
cout << "专业:" << endl;
cin >> Stu[i].mayjor;
cout << "班级" << endl;
cin >> Stu[i].classid;
cout << "学号:" << endl;
cin >> Stu[i].idphone;
while (strlen(Stu[i].idphone) != 10){
cout << "格式有误,请重新输入:" << endl;
cin >> Stu[i].idphone;
}
cout << "姓名:" << endl;
while ((cin >> Stu[i].Name) == 0)//判断姓名输入是否正确
{
cout << "格式有误,请重新输入:" << endl;
}
while (strlen(Stu[i].Name) > 7)
{
cout << "姓名不合理,请重新录入:" << endl;
cin >> Stu[i].Name;
}
cout << "生日:" << endl;
cin >> Stu[i].Birthday;
cout << "年龄:" << endl;
cin >> Stu[i].age;
cout << "家庭住址:" << endl;
cin >> Stu[i].homead;
cout << "学院:" << endl;
cin >> Stu[i].academy;
cout << "性别:";
cin >> Stu[i].sex;
cout << "手机:";
cin >> Stu[i].telephone;
while (strlen(Stu[i].telephone) != 11){
cout << "格式有误,请重新输入:" << endl;
cin >> Stu[i].telephone;
}
cout << "身份证号:";
cin >> Stu[i].number;
while (strlen(Stu[i].number) != 18){
cout << "格式有误,请重新输入:" << endl;
cin >> Stu[i].number;
}
cout << "数学:" << endl;
cin >> Stu[i].math;
cout << "专业:" << endl;
cin >> Stu[i].major;
cout << "英语:" << endl;
cin >> Stu[i].english;
for (int i = 0; i<len; i++)
ofile << Stu[i].mayjor << " " << Stu[i].classid << " " << Stu[i].idphone << " " << Stu[i].Name << " " << Stu[i].Birthday << " " << Stu[i].age << " " << Stu[i].homead << " " << Stu[i].academy << " " << Stu[i].sex << " " << Stu[i].telephone << " " << Stu[i].number << endl;
}
cout << "添加学生成功,请按任意键返回" << endl;
for (int i = 0; i<len; i++){
cout << Stu[i].mayjor << '\t' << Stu[i].classid << '\t' << Stu[i].idphone << '\t' << Stu[i].Name << Stu[i].Birthday << '\t' << Stu[i].age << '\t' << Stu[i].homead << '\t';
cout << Stu[i].academy << '\t' << Stu[i].telephone << '\t' << Stu[i].number << '\t' << Stu[i].major << '\t' << Stu[i].math << '\t' << Stu[i].english << endl;;
}
}
//修改开始
void rewrite1(){//根据学号修改信息
record();
ofstream of;
of.open("E:\\程序设计\\information.txt", ios::app);
char a[20];
int b;
cout << "请输入要修改信息的学生的学号" << endl;
cin >> a;
for (int i = 0; i<Size; i++){
if (a == Stu[i].idphone)
of << "修改学生的姓名:" << Stu[i].Name << Stu[i].idphone;
cout << "1、修改姓名" << endl;
cout << "1、修改姓名" << endl;
cout << "2、修改学号" << endl;
cout << "3、修改高数成绩" << endl;
cout << "4、修改英语成绩" << endl;
cout << "5、修改专业成绩" << endl;
cout << "请选择" << endl;
cin >> b;
switch (b) {
case 1:
cout << "输入修改的姓名" << endl;
of << "修改前的姓名:" << Stu[i].Name;
cin >> Stu[i].Name;
of << "修改后的姓名:" << Stu[i].Name;
break;
case 2:
cout << "输入修改的学号" << endl;
of << "修改前的学号:" << Stu[i].idphone;
cin >> Stu[i].idphone;
of << "修改后的学号:" << Stu[i].idphone;
break;
case 3:
cout << "输入修改的高数成绩" << endl;
of << "修改前的高数成绩:" << Stu[i].math;
cin >> Stu[i].math;
of << "修改后的高数成绩:" << Stu[i].math;
break;
case 4:
cout << "输入修改的英语成绩" << endl;
of << "修改前的英语成绩:" << Stu[i].Name;
cin >> Stu[i].english;
of << "修改后的英语成绩:" << Stu[i].Name;
break;
case 5:
cout << "输入修改的专业成绩" << endl;
of << "修改前的专业成绩:" << Stu[i].Name;
cin >> Stu[i].major;
of << "修改后的专业成绩:" << Stu[i].Name;
break;
default:
break;
} break;
}
ofstream fout("E:\\程序设计\\学生信息2.txt");
for (int i = 0; i < Size; i++){
fout << Stu[i].mayjor << "\t" << Stu[i].classid << "\t" << Stu[i].idphone << "\t" << Stu[i].Name << "\t" << Stu[i].Birthday << "\t" << Stu[i].age << "\t" << Stu[i].homead << "\t" << Stu[i].academy << "\t" << Stu[i].sex << "\t" << Stu[i].telephone << "\t" << Stu[i].number << endl;
}
}
void rewrite(){//姓名修改学生成绩
cout << "请按照提示填入信息:" << endl << endl;
cout << "请输入您的姓名:" << endl;
cout << "请输入您进入该系统所进行的操作:" << endl;
cout << "请输入您的手机号码,以便联系您:" << endl;
record();
char a[10];
int b;
cout << "请输入要修改信息的学生的姓名" << endl;
cin >> a;
for (int i = 0; i<Size; i++){
if (a == Stu[i].Name)
cout << "1、修改姓名" << endl;
cout << "1、修改姓名" << endl;
cout << "2、修改学号" << endl;
cout << "3、修改高数成绩" << endl;
cout << "4、修改英语成绩" << endl;
cout << "5、修改专业成绩" << endl;
cout << "请选择" << endl;
cin >> b;
switch (b) {
case 1:
cout << "输入修改的姓名" << endl;
cin >> Stu[i].Name;
break;
case 2:
cout << "输入修改的学号" << endl;
cin >> Stu[i].idphone;
break;
case 3:
cout << "输入修改的高数成绩" << endl;
cin >> Stu[i].math;
break;
case 4:
cout << "输入修改的英语成绩" << endl;
cin >> Stu[i].english;
break;
case 5:
cout << "输入修改的专业成绩" << endl;
cin >> Stu[i].major;
break;
default:
break;
} break;
}
ofstream fout("E:\\程序设计\\学生信息2.txt");
for (int i = 0; i < Size; i++){
fout << Stu[i].mayjor << "\t" << Stu[i].classid << "\t" << Stu[i].idphone << "\t" << Stu[i].Name << "\t" << Stu[i].Birthday << "\t" << Stu[i].age << "\t" << Stu[i].homead << "\t" << Stu[i].academy << "\t" << Stu[i].sex << "\t" << Stu[i].telephone << "\t" << Stu[i].number << endl;
}
}
void xg(){//批量修改学院和专业
int p; string a; string b;
cout << "批量修改选择:" << endl;
cout << "1.学院" << "\t" << "2.专业" << endl;
cin >> p;
switch (p){
case 1:{
cout << "输入修改后名称:" << endl;
cin >> a;
for (int i = 0; i<Size; i++)
Stu[i].academy = a;
ofstream fout;
fout.open("E:\\程序设计\\学生信息2.txt");
for (int i = 0; i < Size; i++){
fout << Stu[i].mayjor << "\t" << Stu[i].classid << "\t" << Stu[i].idphone << "\t" << Stu[i].Name << "\t" << Stu[i].Birthday << "\t" << Stu[i].age << "\t" << Stu[i].homead << "\t" << Stu[i].academy << "\t" << Stu[i].sex << "\t" << Stu[i].telephone << "\t" << Stu[i].number << endl;
}break; }
case 2:{
cout << "输入修改后名称:" << endl;
cin >> b;
for (int i = 0; i<Size; i++)
Stu[i].mayjor = b;
ofstream fout;
fout.open("E:\\程序设计\\学生信息.txt");
for (int i = 0; i < Size; i++){
fout << Stu[i].mayjor << "\t" << Stu[i].classid << "\t" << Stu[i].idphone << "\t" << Stu[i].Name << "\t" << Stu[i].Birthday << "\t" << Stu[i].age << "\t" << Stu[i].homead << "\t" << Stu[i].academy << "\t" << Stu[i].sex << "\t" << Stu[i].telephone << "\t" << Stu[i].number << endl;
}break; }
}
}
//查询开始
void xmcx(int n)//姓名查询
{
cout << "请按照提示填入信息:" << endl << endl;
cout << "请输入您的姓名:" << endl;
cout << "请输入您进入该系统所进行的操作:" << endl;
cout << "请输入您的手机号码,以便联系您:" << endl;
record();
char findname[20];
cout << "请输入你要查询的学生姓名:";
cin >> findname;
int t = 0; int j = 0;
while (findname[t] != '\0'){ t++; }
j = t / 2;
if (j != 1){
for (int i = 0; i<n; i++){
if (!(strcmp(Stu[i].Name, findname))){
cout << "查询成功!\n" << endl;
cout << "————————————————————\n" << endl;
cout << "专业:" << Stu[i].mayjor << '\n';
cout << "班级:" << Stu[i].classid << '\n';
cout << "学号: " << Stu[i].idphone << '\n';
cout << "姓名:" << Stu[i].Name << '\n';
cout << "生日:" << Stu[i].Birthday << '\n';
cout << "家庭住址:" << Stu[i].homead << '\n';
cout << " 学院 :" << Stu[i].academy << '\n';
cout << "手机号:" << Stu[i].telephone << '\n';
cout << "身份证号:" << Stu[i].number << '\n';
cout << "语文成绩:" << Stu[i].major << '\n';
cout << "数学成绩:" << Stu[i].math << '\n';
cout << "英语成绩:" << Stu[i].english << '\n';
}
}
}
if (j == 1){
for (int i = 0; i<n; i++){
if (Stu[i].Name[0] == findname[0]) {
cout << "查询成功!\n" << endl;
cout << "————————————————————\n" << endl;
cout << "专业:" << Stu[i].mayjor << '\n';
cout << "班级:" << Stu[i].classid << '\n';
cout << "学号: " << Stu[i].idphone << '\n';
cout << "姓名:" << Stu[i].Name << '\n';
cout << "生日:" << Stu[i].Birthday << '\n';
cout << "家庭住址:" << Stu[i].homead << '\n';
cout << "家庭住址: " << Stu[i].homead << '\n';
cout << " 学院 :" << Stu[i].academy << '\n';
cout << "手机号:" << Stu[i].telephone << '\n';
cout << "身份证号:" << Stu[i].number << '\n';
cout << "语文成绩:" << Stu[i].major << '\n';
cout << "数学成绩:" << Stu[i].math << '\n';
cout << "英语成绩:" << Stu[i].english << '\n';
}
}
}
}
void sjcx()//通讯公司查询
{
string s;
cout << "请输入你要查询手机公司名称:"; cin >> s;
if (s == "中国移动"){
int i = 0;
while (i <= Size){
switch (Stu[i].telephone[1]){
case '3':if (Stu[i].telephone[2] == '4' || Stu[i].telephone[2] == '5' || Stu[i].telephone[2] == '6' || Stu[i].telephone[2] == '7' || Stu[i].telephone[2] == '8' || Stu[i].telephone[2] == '9') cout << Stu[i].Name << Stu[i].telephone << endl; break;
case '4':if (Stu[i].telephone[2] == '7') cout << Stu[i].Name << Stu[i].telephone << endl; break;
case '5':if (Stu[i].telephone[2] == '0' || Stu[i].telephone[2] == '1' || Stu[i].telephone[2] == '2' || Stu[i].telephone[2] == '7' || Stu[i].telephone[2] == '8' || Stu[i].telephone[2] == '9') cout << Stu[i].Name << Stu[i].telephone << endl; break;
case '7':if (Stu[i].telephone[2] == '2' || Stu[i].telephone[2] == '8') cout << Stu[i].Name << Stu[i].telephone << endl; break;
case '8':if (Stu[i].telephone[2] == '2' || Stu[i].telephone[2] == '3' || Stu[i].telephone[2] == '4' || Stu[i].telephone[2] == '7' || Stu[i].telephone[2] == '8') cout << Stu[i].Name << Stu[i].telephone << endl; break;
case '9':if (Stu[i].telephone[2] == '5' || Stu[i].telephone[2] == '7') cout << Stu[i].Name << Stu[i].telephone << endl; break;
}
i++;
}
}
if (s == "中国联通"){
int i = 0;
while (i <= Size){
switch (Stu[i].telephone[1]){
case '3':if (Stu[i].telephone[2] == '0' || Stu[i].telephone[2] == '1' || Stu[i].telephone[2] == '2') cout << Stu[i].Name << Stu[i].telephone << endl; break;
case '5':if (Stu[i].telephone[2] == '5' || Stu[i].telephone[2] == '6') cout << Stu[i].Name << Stu[i].telephone << endl; break;
case '7':if (Stu[i].telephone[2] == '6') cout << Stu[i].Name << Stu[i].telephone << endl; break;
case '8':if (Stu[i].telephone[2] == '5' || Stu[i].telephone[2] == '6') cout << Stu[i].Name << Stu[i].telephone << endl; break;
}
i++;
}
}
if (s == "中国电信"){
int i = 0;
while (i <= Size){
switch (Stu[i].telephone[1]){
case '3':if (Stu[i].telephone[2] == '3') cout << Stu[i].Name << Stu[i].telephone << endl; break;
case '5':if (Stu[i].telephone[2] == '3') cout << Stu[i].Name << Stu[i].telephone << endl; break;
case '8':if (Stu[i].telephone[2] == '0' || Stu[i].telephone[2] == '1' || Stu[i].telephone[2] == '9') cout << Stu[i].Name << Stu[i].telephone << endl; break;
}
i++;
}
}
}
void bjcx()//班级号查询
{
string banji;
cout << "请输入要查询的班级号:";
cin >> banji;
for (int i = 0; i <Size; i++)
{
if (Stu[i].classid == banji)
{
cout << "学院:" << Stu[i].academy << endl;
cout << "班级:" << Stu[i].classid << endl;
cout << "学号:" << Stu[i].idphone << endl;
cout << "姓名:" << Stu[i].Name << endl;
cout << "性别:" << Stu[i].sex << endl;
cout << "专业:" << Stu[i].major << endl;
cout << "数学:" << Stu[i].math << endl;
cout << "英语:" << Stu[i].english << endl;
}
}
}
void xhcx()//学号查询
{
string id;
cin >> id;
for (int i = 0; i < Size; i++)
{
if (id == Stu[i].idphone)
{
cout << "学院:" << Stu[i].academy << endl;
cout << "班级:" << Stu[i].classid << endl;
cout << "学号:" << Stu[i].idphone << endl;
cout << "姓名:" << Stu[i].Name << endl;
cout << "性别:" << Stu[i].sex << endl;
cout << "专业:" << Stu[i].major << endl;
cout << "数学:" << Stu[i].math << endl;
cout << "英语:" << Stu[i].english << endl;
}
}
}
void dkcx(){//根据学号查询课程
cout << "1.语文" << endl << "2.数学" << endl << "3.英语" << endl;
cout << "请选择:" << endl;
int flag;
cin >> flag;
switch (flag){
case 1:system("cls"); yw(); break;
case 2:system("cls"); sx(); break;
case 3:system("cls"); yy(); break;
}
}
//专业查询
void yw(){
string id;
cout << "请输入要查询的学号:" << endl;
cin >> id;
for (int i = 0; i < Size; i++)
if (Stu[i].idphone == id)
{
cout << "学院:" << Stu[i].academy << endl;
cout << "班级:" << Stu[i].classid << endl;
cout << "学号:" << Stu[i].idphone << endl;
cout << "姓名:" << Stu[i].Name << endl;
cout << "性别:" << Stu[i].sex << endl;
cout << "专业:" << Stu[i].major << endl;
}
}
//英语查询
void yy(){
string id;
cout << "请输入要查询的学号:" << endl;
cin >> id;
for (int i = 0; i < Size; i++)
if (Stu[i].idphone == id){
cout << "学院:" << Stu[i].academy << endl;
cout << "班级:" << Stu[i].classid << endl;
cout << "学号:" << Stu[i].idphone << endl;
cout << "姓名:" << Stu[i].Name << endl;
cout << "性别:" << Stu[i].sex << endl;
cout << "英语:" << Stu[i].english << endl;
}
}
//数学查询
void sx(){
string id;
cout << "请输入要查询的学号:" << endl;
cin >> id;
for (int i = 0; i < Size; i++)
if (Stu[i].idphone == id){
cout << "学院:" << Stu[i].academy << endl;
cout << "班级:" << Stu[i].classid << endl;
cout << "学号:" << Stu[i].idphone << endl;
cout << "姓名:" << Stu[i].Name << endl;
cout << "性别:" << Stu[i].sex << endl;
cout << "数学:" << Stu[i].math << endl;
}
}
void bjgcx(){//不及格查询
cout << "请选择要查询的科目:" << endl << "1.语文:" << endl << "2.数学:" << endl << "3.英语:" << endl;
int flag;
cin >> flag;
switch (flag){
case 1:system("cls"); zybjg(); break;
case 2:system("cls"); sxbjg(); break;
case 3:system("cls"); yybjg(); break;
}
}
//4.1语文不及格
void zybjg(){
for (int i = 0; i < Size; i++)
if (Stu[i].major<60)
{
cout << "学院:" << Stu[i].academy << endl;
cout << "班级:" << Stu[i].classid << endl;
cout << "学号:" << Stu[i].idphone << endl;
cout << "姓名:" << Stu[i].Name << endl;
cout << "性别:" << Stu[i].sex << endl;
cout << "专业:" << Stu[i].major << endl;
}
}
//4.2数学不及格
void sxbjg(){
for (int i = 0; i < Size; i++)
if (Stu[i].math<60)
{
cout << "学院:" << Stu[i].academy << endl;
cout << "班级:" << Stu[i].classid << endl;
cout << "学号:" << Stu[i].idphone << endl;
cout << "姓名:" << Stu[i].Name << endl;
cout << "性别:" << Stu[i].sex << endl;
cout << "数学:" << Stu[i].math << endl;
}
}
//4.3英语不及格
void yybjg(){
for (int i = 0; i < Size; i++)
if (Stu[i].english < 60)
{
cout << "学院:" << Stu[i].academy << endl;
cout << "班级:" << Stu[i].classid << endl;
cout << "学号:" << Stu[i].idphone << endl;
cout << "姓名:" << Stu[i].Name << endl;
cout << "性别:" << Stu[i].sex << endl;
cout << "英语:" << Stu[i].english << endl;
}
}
void xmcx()//姓名查询
{
cout << "请按照提示填入信息:" << endl << endl;
cout << "请输入您的姓名:" << endl;
cout << "请输入您进入该系统所进行的操作:" << endl;
cout << "请输入您的手机号码,以便联系您:" << endl;
char findname[20];
cout << "请输入你要查询的学生姓名:";
cin >> findname;
int t = 0; int j = 0;
while (findname[t] != '\0'){ t++; }
j = t / 2;
if (j != 1){
for (int i = 0; i<Size; i++){
if (!(strcmp(Stu[i].Name, findname))){
cout << "查询成功!\n" << endl;
cout << "————————————————————\n" << endl;
cout << "专业:" << Stu[i].mayjor << '\n';
cout << "班级:" << Stu[i].classid << '\n';
cout << "学号: " << Stu[i].idphone << '\n';
cout << "姓名:" << Stu[i].Name << '\n';
cout << "生日:" << Stu[i].Birthday << '\n';
cout << "家庭住址:" << Stu[i].homead << '\n';
cout << " 学院 :" << Stu[i].academy << '\n';
cout << "手机号:" << Stu[i].telephone << '\n';
cout << "身份证号:" << Stu[i].number << '\n';
cout << "语文成绩:" << Stu[i].major << '\n';
cout << "数学成绩:" << Stu[i].math << '\n';
cout << "英语成绩:" << Stu[i].english << '\n';
}
}
}
if (j == 1){
for (int i = 0; i<Size; i++){
if (Stu[i].Name[0] == findname[0]) {
cout << "查询成功!\n" << endl;
cout << "————————————————————\n" << endl;
cout << "专业:" << Stu[i].mayjor << '\n';
cout << "班级:" << Stu[i].classid << '\n';
cout << "学号: " << Stu[i].idphone << '\n';
cout << "姓名:" << Stu[i].Name << '\n';
cout << "生日:" << Stu[i].Birthday << '\n';
cout << "家庭住址:" << Stu[i].homead << '\n';
cout << "家庭住址: " << Stu[i].homead << '\n';
cout << " 学院 :" << Stu[i].academy << '\n';
cout << "手机号:" << Stu[i].telephone << '\n';
cout << "身份证号:" << Stu[i].number << '\n';
cout << "语文成绩:" << Stu[i].major << '\n';
cout << "数学成绩:" << Stu[i].math << '\n';
cout << "英语成绩:" << Stu[i].english << '\n';
}
}
}
}
//删除开始
void deletemess1(){//学号,姓名删除信息
char key = '0';
ofstream ofile;
ofstream of;
of.open("E:\\程序设计\\information.txt", ios::app);
ofile.open("E:\\程序设计\\学生信息.txt");
cout << "输入1代表按学号删除单个数据,其他代表按姓名删除" << endl;
cin >> key; int i = 0;
if (key == '1'){
string deletenum;
cout << "请输入删除学生的考号:" << endl;
cin >> deletenum;
for (; i<Size; i++){
if (Stu[i].idphone != deletenum){
cout << Stu[i].mayjor << "\t" << Stu[i].classid << "\t" << Stu[i].idphone << "\t" << Stu[i].Name << "\t" << Stu[i].Birthday << "\t" << Stu[i].age << "\t" << Stu[i].homead << "\t" << Stu[i].academy << "\t" << Stu[i].sex << "\t" << Stu[i].telephone << "\t" << Stu[i].number << endl;
ofile << Stu[i].mayjor << " " << Stu[i].classid << " " << Stu[i].idphone << " " << Stu[i].Name << " " << Stu[i].Birthday << " " << Stu[i].age << " " << Stu[i].homead << " " << Stu[i].academy << " " << Stu[i].sex << " " << Stu[i].telephone << " " << Stu[i].number << endl;
}
else {
of << "删除的学生信息:" << endl;
of << Stu[i].mayjor << "\t" << Stu[i].classid << "\t" << Stu[i].idphone << "\t" << Stu[i].Name << "\t" << Stu[i].Birthday << "\t" << Stu[i].age << "\t" << Stu[i].homead << "\t" << Stu[i].academy << "\t" << Stu[i].sex << "\t" << Stu[i].telephone << "\t" << Stu[i].number << endl;
}
}
}
if (key != '1'){
string deletename;
cout << "请输入删除学生的姓名:" << endl;
cin >> deletename;
for (int i = 0; i<Size; i++){
if (Stu[i].Name != deletename){
cout << Stu[i].mayjor << "\t" << Stu[i].classid << "\t" << Stu[i].idphone << "\t" << Stu[i].Name << "\t" << Stu[i].Birthday << "\t" << Stu[i].age << "\t" << Stu[i].homead << "\t" << Stu[i].academy << "\t" << Stu[i].sex << "\t" << Stu[i].telephone << "\t" << Stu[i].number << endl;
ofile << Stu[i].mayjor << " " << Stu[i].classid << " " << Stu[i].idphone << " " << Stu[i].Name << " " << Stu[i].Birthday << " " << Stu[i].age << " " << Stu[i].homead << " " << Stu[i].academy << " " << Stu[i].sex << " " << Stu[i].telephone << " " << Stu[i].number << endl;
}
else {
of << "删除的学生信息:" << endl;
of << Stu[i].mayjor << "\t" << Stu[i].classid << "\t" << Stu[i].idphone << "\t" << Stu[i].Name << "\t" << Stu[i].Birthday << "\t" << Stu[i].age << "\t" << Stu[i].homead << "\t" << Stu[i].academy << "\t" << Stu[i].sex << "\t" << Stu[i].telephone << "\t" << Stu[i].number << endl;
}
}
}
}
void deletemess3(){//输入专业和班级信息,根据学号删除本班全班同学信息
ofstream ofile;
ofile.open("E:\\程序设计\\学生信息.txt");
string declass;
string demayjor;
ofstream of;
of.open("E:\\程序设计\\information.txt", ios::app);
cout << "请输入班级的专业;" << endl;
cin >> demayjor;
cout << "请输入班级;" << endl;
cin >> declass;
cout << "输出删除后的信息" << endl;
for (int i = 0; i<Size; i++)
if ((Stu[i].classid != declass) || (Stu[i].mayjor != demayjor))
{
cout << Stu[i].mayjor << "\t" << Stu[i].classid << "\t" << Stu[i].idphone << "\t" << Stu[i].Name << "\t" << Stu[i].Birthday << "\t" << Stu[i].age << "\t" << Stu[i].homead << "\t" << Stu[i].academy << "\t" << Stu[i].sex << "\t" << Stu[i].telephone << "\t" << Stu[i].number << endl;
ofile << Stu[i].mayjor << " " << Stu[i].classid << " " << Stu[i].idphone << " " << Stu[i].Name << " " << Stu[i].Birthday << " " << Stu[i].age << " " << Stu[i].homead << " " << Stu[i].academy << " " << Stu[i].sex << " " << Stu[i].telephone << " " << Stu[i].number << endl;
}
else {
of << "删除的学生信息:" << endl;
of << Stu[i].mayjor << "\t" << Stu[i].classid << "\t" << Stu[i].idphone << "\t" << Stu[i].Name << "\t" << Stu[i].Birthday << "\t" << Stu[i].age << "\t" << Stu[i].homead << "\t" << Stu[i].academy << "\t" << Stu[i].sex << "\t" << Stu[i].telephone << "\t" << Stu[i].number << endl;
}
cout << "删除完成!" << endl;
}
void deleteforidphone(){ //通过学号删除全班,先获取学号,再通过学号获取班级信息,删除对应班级信息
cout << "请输入要删除所在班级所有学生信息的学号";
string xuehao;
string banji;
cin >> xuehao;
for (int c = 0; c < Size; c++)
{
if (Stu[c].idphone == xuehao)
{
banji = Stu[c].classid; break;//获取班级号
}
}
int x = 0;
ofstream fp;//输出到文件
fp.open("E:\\程序设计\\中转文件.txt");
for (int b = 0; b < Size; b++)
{
if (Stu[b].classid != banji)
{
fp << Stu[b].mayjor << '\t' << Stu[b].classid << '\t' << Stu[b].idphone << '\t' << Stu[b].Name << '\t';
fp << Stu[b].Birthday << '\t' << Stu[b].age << '\t' << Stu[b].homead << '\t' << Stu[b].academy << '\t' << Stu[b].sex << '\t' << Stu[b].telephone << '\t' << Stu[b].number << '\t';
fp << Stu[b].major << '\t' << Stu[b].math << '\t' << Stu[b].english << endl;
}
else{ x++; }//获取班级一共多少人
}
cout << "转存成功!!!" << endl;//上面的ok
ifstream dr;
dr.open("E:\\程序设计\\中转文件.txt");
int i = 0;
for (; i < Size - x; i++)//读入到内存进行删除后覆盖原文件
{
dr >> Stu[i].mayjor >> Stu[i].classid >> Stu[i].idphone >> Stu[i].Name;
dr >> Stu[i].Birthday >> Stu[i].age >> Stu[i].homead >> Stu[i].academy >> Stu[i].sex >> Stu[i].telephone >> Stu[i].number;
dr >> Stu[i].major >> Stu[i].math >> Stu[i].english;
}
ofstream op;
op.open("E:\\程序设计\\学生信息.txt");
int a = 0;
for (a; a < Size - x; a++)
{
op << Stu[a].mayjor << '\t' << Stu[a].classid << '\t' << Stu[a].idphone << '\t' << Stu[a].Name << '\t';
op << Stu[a].Birthday << '\t' << Stu[a].age << '\t' << Stu[a].homead << '\t' << Stu[a].academy << '\t' << Stu[a].sex << '\t' << Stu[a].telephone << '\t' << Stu[a].number << '\t';
op << Stu[a].major << '\t' << Stu[a].math << '\t' << Stu[a].english << endl;
}
cout << "删除成功!!!" << endl;
}
//排序开始
void paixu(){// 实现输入班级、实现按总成绩降序输出学生基本信息与成绩信息。
student x;
string findid;
cout << "请输入查询班级:" << endl;
cin >> findid;
int q = 1;
for (int i = 0; i<Size; i++){
Stu[i].sumcj = Stu[i].major + Stu[i].math + Stu[i].english;
}
for (int i = 1; i<Size; i++){
for (int j = 0; j<Size - i; j++){
if (Stu[j].sumcj>Stu[j + 1].sumcj){
{ x = Stu[j];
Stu[j] = Stu[j + 1];
Stu[j + 1] = x;
}
}
}
}
for (int i = Size - 1; i>0; i--) {
if (Stu[i].classid == findid){
cout << "第" << q << "名:" << '\t';
cout << Stu[i].Name << '\t' << Stu[i].sumcj << endl; q++;
}
}
}
void paixu2(){//实现专业,输出给定课程成绩降序排序的学生成绩及学生信息。
student x;
string findid;
cout << "请输入查询专业:" << endl;
cin >> findid;
int q = 1;
for (int i = 1; i<Size; i++){
for (int j = 0; j<Size - i; j++){
if (Stu[j].sumcj>Stu[j + 1].sumcj){
{ x = Stu[j];
Stu[j] = Stu[j + 1];
Stu[j + 1] = x;
}
}
}
}
for (int i = Size - 1; i >= 0; i--) {
if (Stu[i].mayjor == findid){
cout << Stu[i].Name << '\t' << Stu[i].sumcj << endl;
}
}
}
void paixu3(){//按总成绩降序输出学生基本信息与成绩信息
student b;
for (int i = 1; i<Size; i++){
for (int j = 0; j<Size - i; j++){
if (Stu[j].sumcj<Stu[j + 1].sumcj){
{ b = Stu[j];
Stu[j] = Stu[j + 1];
Stu[j + 1] = b;
}
}
}
}//按总成绩降序排序
for (int k = 0; k<Size; k++){
if (Stu[k].sumcj == Stu[k + 1].sumcj){
if (Stu[k].idphone>Stu[k + 1].idphone){
student t;
t = Stu[k]; Stu[k] = Stu[k + 1]; Stu[k + 1] = t;
}
}
}//若成绩相同时,按学号升序排序
for (int i = 0; i<Size; i++){
cout << Stu[i].mayjor << '\t' << Stu[i].classid << '\t' << Stu[i].idphone << '\t' << Stu[i].Name << Stu[i].Birthday << '\t' << Stu[i].age << '\t' << Stu[i].homead << '\t';
cout << Stu[i].academy << '\t' << Stu[i].telephone << '\t' << Stu[i].number << '\t' << Stu[i].major << '\t' << Stu[i].math << '\t' << Stu[i].english << '\t' << Stu[i].sumcj << endl;;
}
}
//图
int Len = 0;
void tumenu(){
int flag;
cout << "1.折线图" << endl << "2.柱状图" << endl << "3.退出" << endl;
cin >> flag;
switch (flag){
case 1:zxtmenu();
case 2:zztmenu();
case 3:exit(0);
}
}
//查询某个班的所有人
void shuju(string banji, student b[]){
for (int i = 0; i < Size; i++)
{
if (Stu[i].classid == banji)
{
cout << "学院:" << Stu[i].academy << endl;
cout << "班级:" << Stu[i].classid << endl;
cout << "学号:" << Stu[i].idphone << endl;
cout << "姓名:" << Stu[i].Name << endl;
cout << "性别:" << Stu[i].sex << endl;
cout << "专业:" << Stu[i].major << endl;
cout << "数学:" << Stu[i].math << endl;
cout << "英语:" << Stu[i].english << endl;
b[Len++] = Stu[i];
}
}
cout << endl << endl << endl;
}
void zxtmenu(){
string banji;
student *b = new student[100];
cout << "请输入要查询的班级号:";
cin >> banji;
shuju(banji, b);
int flag;
cout << "1.专业课成绩折线图" << endl << "2.数学成绩折线图" << endl << "3.英语成绩折线图" << endl << "4.返回" << endl;
cin >> flag;
switch (flag){
case 1:{majoryzxt(b); break; }
case 2:{mathzxt(b); break; }
case 3:{englishzxt(b); break; }
case 4:tumenu();
}
}
void zztmenu(){
string banji;
student *b = new student[100];
cout << "请输入要查询的班级号:";
cin >> banji;
shuju(banji, b);
cout << " 请选择您想绘制柱状图的课程成绩:" << endl;
cout << " |1.专业成绩 2.数学成绩 3.英语成绩 4.退出" << endl;
int t;
cin >> t;
switch (t){
case 1:{majorzzt(b); break; }
case 2:{mathzzt(b); break; }
case 3:{englishzzt(b); break; }
case 4:tumenu();
}
}
void zbiao(){
initgraph(1000, 800, SHOWCONSOLE);//显示绘图环境 并 显示控制台!!!!!最后那个showconsole就是显示控制台,如果没有这个就只有绘图的那个框
//控制台就是日常编程那个黑色的窗口
//这里定义绘图窗口的大小
//电脑屏幕的大小是1920*1080 像素
//这个 绘图环境有横纵坐标
//坐标原点是窗口的左上
//所以所有的点都要从原点确定长度
//按这个逻辑,电脑左上角坐标是(0.0)右下角为(1920.1080) 格式是(x,y)
line(40, 100, 40, 500);//line函数是连线函数,格式是line(x1,y1,x2,y2),将点(x1,y1)(x2,y2)连起来
line(40, 500, 760, 500);//这两个点的坐标也是参考出现的的窗口左上角为原点
/*putpixel(200, 50, RED); 这是一个描点函数,在坐标(200.50)点画red色的点,特别小 基本看不见 用不到,就没用*/
outtextxy(15, 501, "0");//outtextxy(x,y,"字符") 即在x,y 打一个“”里的字符
outtextxy(33, 100, "↑");
outtextxy(760, 493, "→");
outtextxy(10, 461, "2");
outtextxy(10, 421, "4");
outtextxy(10, 381, "6");
outtextxy(10, 341, "8");
outtextxy(10, 301, "10");
outtextxy(10, 261, "12");
outtextxy(10, 221, "14");
outtextxy(10, 181, "16");
outtextxy(10, 141, "18");
outtextxy(10, 101, "20");
outtextxy(14, 81, "/");
outtextxy(18, 80, "人");
outtextxy(50, 501, "不及格");
outtextxy(120, 501, "60-65");
outtextxy(190, 501, "65-70");
outtextxy(260, 501, "70-75");
outtextxy(330, 501, "75-80");
outtextxy(400, 501, "80-85");
outtextxy(470, 501, "85-90");
outtextxy(540, 501, "90-95");
outtextxy(610, 501, "95-100");
outtextxy(730, 501, "/");
outtextxy(735, 501, "分");
}
void majoryzxt(student b[]){
int ten1 = 0, ten2 = 0, ten3 = 0, ten4 = 0, ten5 = 0, ten6 = 0, ten7 = 0, ten8 = 0, ten9 = 0, ten10 = 0;
for (int i = 0; i < Len; i++)
{
if (b[i].major < 60) ten1++;
else if (60 <= b[i].major && b[i].major < 65) ten2++;
else if (65 <= b[i].major&& b[i].major < 70) ten3++;
else if (70 <= b[i].major && b[i].major < 75) ten4++;
else if (75 <= b[i].major && b[i].major < 80) ten5++;
else if (80 <= b[i].major && b[i].major < 85) ten6++;
else if (85 <= b[i].major && b[i].major < 90) ten7++;
else if (90 <= b[i].major && b[i].major < 95) ten8++;
else ten9++;
}
zbiao();
line(40, 501, 60, (501 - 19 * ten1));
line(60, (501 - 19 * ten1), 130, (501 - 19 * ten2));//line函数是连线函数,格式是line(x1,y1,x2,y2),将点(x1,y1)(x2,y2)连起来
line(130, (501 - 19 * ten2), 200, (501 - 19 * ten3));
line(200, (501 - 19 * ten3), 270, (501 - 19 * ten4));
line(270, (501 - 19 * ten4), 340, (501 - 19 * ten5));
line(340, (501 - 19 * ten5), 410, (501 - 19 * ten6));
line(410, (501 - 19 * ten6), 480, (501 - 19 * ten7));
line(480, (501 - 19 * ten7), 550, (501 - 19 * ten8));
line(550, (501 - 19 * ten8), 620, (501 - 19 * ten9));
system("pause");
closegraph();//关闭图形系统
zxtmenu();
}
void mathzxt(student b[]){
int ten1 = 0, ten2 = 0, ten3 = 0, ten4 = 0, ten5 = 0, ten6 = 0, ten7 = 0, ten8 = 0, ten9 = 0, ten10 = 0;
for (int i = 0; i < Len; i++)
{
if (b[i].math < 60) ten1++;
else if (60 <= b[i].math && b[i].math < 65) ten2++;
else if (65 <= b[i].math && b[i].math < 70) ten3++;
else if (70 <= b[i].math &&b[i].math < 75) ten4++;
else if (75 <= b[i].math && b[i].math < 80) ten5++;
else if (80 <= b[i].math && b[i].math < 85) ten6++;
else if (85 <= b[i].math && b[i].math < 90) ten7++;
else if (90 <= b[i].math && b[i].math < 95) ten8++;
else ten9++;
}
zbiao();
line(40, 501, 60, (501 - 19 * ten1));
line(60, (501 - 19 * ten1), 130, (501 - 19 * ten2));
line(130, (501 - 19 * ten2), 200, (501 - 19 * ten3));
line(200, (501 - 19 * ten3), 270, (501 - 19 * ten4));
line(270, (501 - 19 * ten4), 340, (501 - 19 * ten5));
line(340, (501 - 19 * ten5), 410, (501 - 19 * ten6));
line(410, (501 - 19 * ten6), 480, (501 - 19 * ten7));
line(480, (501 - 19 * ten7), 550, (501 - 19 * ten8));
line(550, (501 - 19 * ten8), 620, (501 - 19 * ten9));
system("pause");
closegraph();//关闭图形系统
zxtmenu();
}
void englishzxt(student b[]){
int ten1 = 0, ten2 = 0, ten3 = 0, ten4 = 0, ten5 = 0, ten6 = 0, ten7 = 0, ten8 = 0, ten9 = 0, ten10 = 0;
for (int i = 0; i < Len; i++)
{
if (b[i].english < 60) ten1++;
else if (60 <= b[i].english && b[i].english < 65) ten2++;
else if (65 <= b[i].english && b[i].english < 70) ten3++;
else if (70 <= b[i].english && b[i].english < 75) ten4++;
else if (75 <= b[i].english && b[i].english< 80) ten5++;
else if (80 <= b[i].english && b[i].english < 85) ten6++;
else if (85 <= b[i].english && b[i].english < 90) ten7++;
else if (90 <= b[i].english && b[i].english < 95) ten8++;
else ten9++;
}
zbiao();
line(40, 501, 60, (501 - 19 * ten1));
line(60, (501 - 19 * ten1), 130, (501 - 19 * ten2));
line(130, (501 - 19 * ten2), 200, (501 - 19 * ten3));
line(200, (501 - 19 * ten3), 270, (501 - 19 * ten4));
line(270, (501 - 19 * ten4), 340, (501 - 19 * ten5));
line(340, (501 - 19 * ten5), 410, (501 - 19 * ten6));
line(410, (501 - 19 * ten6), 480, (501 - 19 * ten7));
line(480, (501 - 19 * ten7), 550, (501 - 19 * ten8));
line(550, (501 - 19 * ten8), 620, (501 - 19 * ten9));
system("pause");
closegraph();//关闭图形系统
zxtmenu();
}
void majorzzt(student b[]) {
int ten1 = 0, ten2 = 0, ten3 = 0, ten4 = 0, ten5 = 0, ten6 = 0, ten7 = 0, ten8 = 0, ten9 = 0, ten10 = 0;
for (int i = 0; i < Len; i++)
{
if (b[i].major < 60) ten1++;
else if (60 <= b[i].major && b[i].major < 65) ten2++;
else if (65 <= b[i].major && b[i].major < 70) ten3++;
else if (70 <= b[i].major && b[i].major < 75) ten4++;
else if (75 <= b[i].major && b[i].major < 80) ten5++;
else if (80 <= b[i].major && b[i].major < 85) ten6++;
else if (85 <= b[i].major && b[i].major < 90) ten7++;
else if (90 <= b[i].major && b[i].major < 95) ten8++;
else ten9++;
}
zbiao();
//不及格
line(60, 500, 60, 500 - ten1 * 20);
line(60, (500 - ten1 * 20), 80, (500 - 20 * ten1));
line(80, 500 - 20 * ten1, 80, 500);
//60-65
line(130, 500, 130, 500 - 20 * ten2);
line(130, 500 - 20 * ten2, 150, 500 - 20 * ten2);
line(150, 500 - 20 * ten2, 150, 500);
//65-70
line(200, 500, 200, 500 - 20 * ten3);
line(200, 500 - 20 * ten3, 220, 500 - 20 * ten3);
line(220, 500 - 20 * ten3, 220, 500);
//70-75
line(270, 500, 270, 500 - 20 * ten4);
line(270, 500 - 20 * ten4, 290, 500 - 20 * ten4);
line(290, 500 - 20 * ten4, 290, 500);
//75-80
line(340, 500, 340, 500 - 20 * ten5);
line(340, 500 - 20 * ten5, 360, 500 - 20 * ten5);
line(360, 500 - 20 * ten5, 360, 500);
//80-85
line(410, 500, 410, 500 - 20 * ten6);
line(410, 500 - 20 * ten6, 430, 500 - 20 * ten6);
line(430, 500 - 20 * ten6, 430, 500);
//85-90
line(480, 500, 480, 500 - 20 * ten7);
line(480, 500 - 20 * ten7, 500, 500 - 20 * ten7);
line(500, 500 - 20 * ten7, 500, 500);
//90-95
line(550, 500, 550, 500 - 20 * ten8);
line(550, 500 - 20 * ten8, 570, 500 - 20 * ten8);
line(570, 500 - 20 * ten8, 570, 500);
//95-100
line(620, 500, 620, 500 - 20 * ten9);
line(620, 500 - 20 * ten9, 640, 500 - 20 * ten9);
line(640, 500 - 20 * ten9, 640, 500);
system("pause");
closegraph();//关闭图形系统
zztmenu();
}
void mathzzt(student b[]){
int ten1 = 0, ten2 = 0, ten3 = 0, ten4 = 0, ten5 = 0, ten6 = 0, ten7 = 0, ten8 = 0, ten9 = 0, ten10 = 0;
for (int i = 0; i < Len; i++)
{
if (b[i].math < 60) ten1++;
else if (60 <= b[i].math && b[i].math < 65) ten2++;
else if (65 <= b[i].math && b[i].math < 70) ten3++;
else if (70 <= b[i].math && b[i].math < 75) ten4++;
else if (75 <= b[i].math && b[i].math < 80) ten5++;
else if (80 <= b[i].math && b[i].math < 85) ten6++;
else if (85 <= b[i].math && b[i].math < 90) ten7++;
else if (90 <= b[i].math && b[i].math < 95) ten8++;
else ten9++;
}
zbiao();
//不及格
line(60, 500, 60, 500 - ten1 * 20);
line(60, (500 - ten1 * 20), 80, (500 - 20 * ten1));
line(80, 500 - 20 * ten1, 80, 500);
//60-65
line(130, 500, 130, 500 - 20 * ten2);
line(130, 500 - 20 * ten2, 150, 500 - 20 * ten2);
line(150, 500 - 20 * ten2, 150, 500);
//65-70
line(200, 500, 200, 500 - 20 * ten3);
line(200, 500 - 20 * ten3, 220, 500 - 20 * ten3);
line(220, 500 - 20 * ten3, 220, 500);
//70-75
line(270, 500, 270, 500 - 20 * ten4);
line(270, 500 - 20 * ten4, 290, 500 - 20 * ten4);
line(290, 500 - 20 * ten4, 290, 500);
//75-80
line(340, 500, 340, 500 - 20 * ten5);
line(340, 500 - 20 * ten5, 360, 500 - 20 * ten5);
line(360, 500 - 20 * ten5, 360, 500);
//80-85
line(410, 500, 410, 500 - 20 * ten6);
line(410, 500 - 20 * ten6, 430, 500 - 20 * ten6);
line(430, 500 - 20 * ten6, 430, 500);
//85-90
line(480, 500, 480, 500 - 20 * ten7);
line(480, 500 - 20 * ten7, 500, 500 - 20 * ten7);
line(500, 500 - 20 * ten7, 500, 500);
//90-95
line(550, 500, 550, 500 - 20 * ten8);
line(550, 500 - 20 * ten8, 570, 500 - 20 * ten8);
line(570, 500 - 20 * ten8, 570, 500);
//95-100
line(620, 500, 620, 500 - 20 * ten9);
line(620, 500 - 20 * ten9, 640, 500 - 20 * ten9);
line(640, 500 - 20 * ten9, 640, 500);
system("pause");
closegraph();//关闭图形系统
zztmenu();
}
void englishzzt(student b[]){
int ten1 = 0, ten2 = 0, ten3 = 0, ten4 = 0, ten5 = 0, ten6 = 0, ten7 = 0, ten8 = 0, ten9 = 0, ten10 = 0;
for (int i = 0; i < Len; i++)
{
if (b[i].english < 60) ten1++;
else if (60 <= b[i].english && b[i].english < 65) ten2++;
else if (65 <= b[i].english && b[i].english < 70) ten3++;
else if (70 <= b[i].english && b[i].english < 75) ten4++;
else if (75 <= b[i].english && b[i].english < 80) ten5++;
else if (80 <= b[i].english && b[i].english < 85) ten6++;
else if (85 <= b[i].english && b[i].english < 90) ten7++;
else if (90 <= b[i].english && b[i].english < 95) ten8++;
else ten9++;
}
zbiao();
//不及格
line(60, 500, 60, 500 - ten1 * 20);
line(60, (500 - ten1 * 20), 80, (500 - 20 * ten1));
line(80, 500 - 20 * ten1, 80, 500);
//60-65
line(130, 500, 130, 500 - 20 * ten2);
line(130, 500 - 20 * ten2, 150, 500 - 20 * ten2);
line(150, 500 - 20 * ten2, 150, 500);
//65-70
line(200, 500, 200, 500 - 20 * ten3);
line(200, 500 - 20 * ten3, 220, 500 - 20 * ten3);
line(220, 500 - 20 * ten3, 220, 500);
//70-75
line(270, 500, 270, 500 - 20 * ten4);
line(270, 500 - 20 * ten4, 290, 500 - 20 * ten4);
line(290, 500 - 20 * ten4, 290, 500);
//75-80
line(340, 500, 340, 500 - 20 * ten5);
line(340, 500 - 20 * ten5, 360, 500 - 20 * ten5);
line(360, 500 - 20 * ten5, 360, 500);
//80-85
line(410, 500, 410, 500 - 20 * ten6);
line(410, 500 - 20 * ten6, 430, 500 - 20 * ten6);
line(430, 500 - 20 * ten6, 430, 500);
//85-90
line(480, 500, 480, 500 - 20 * ten7);
line(480, 500 - 20 * ten7, 500, 500 - 20 * ten7);
line(500, 500 - 20 * ten7, 500, 500);
//90-95
line(550, 500, 550, 500 - 20 * ten8);
line(550, 500 - 20 * ten8, 570, 500 - 20 * ten8);
line(570, 500 - 20 * ten8, 570, 500);
//95-100
line(620, 500, 620, 500 - 20 * ten9);
line(620, 500 - 20 * ten9, 640, 500 - 20 * ten9);
line(640, 500 - 20 * ten9, 640, 500);
system("pause");
closegraph();//关闭图形系统
zztmenu();
}
};
int main(){
studentlock();
teacherlock();
userlock();
cout << endl;
student a;
start();
int choice;
cout << "\t\t\t┏━━━━━━━━━━━━━━━━━━━━━━━━┓\n";
cout << "\t\t\t┃ 1.学生 2.老师 3.管理员 \t\n";
cout << "\t\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━┛\n";
cout << "\t\t\t【系统提示】请输入你的选择:";
cin >> choice;
switch (choice){
case 1:{cout << "\t\t\t【系统提示】请输入学号:";
a.inputinfo();
int p = 1;
string id;
cin >> id; int i = 0;
for (; i < a.Size; i++){
if (id == a.Stu[i].idphone&&p == mima(a.Stu[i].mi)){
cout << "\t\t\t【系统提示】登录成功!" << endl;
studentunlock();
cout << endl;
while (1){
cout << "\t\t\t【系统提示】1.查看个人信息 2.查看成绩 3.退出系统" << endl;
cout << "\t\t\t【系统提示】请输入你的选择:";
int t; cin >> t;
cout << endl;
if (t == 1) {
cout << a.Stu[i].mayjor << '\t' << a.Stu[i].classid << '\t' << a.Stu[i].idphone << '\t' << a.Stu[i].Name << a.Stu[i].Birthday << '\t' << a.Stu[i].age << '\t' << a.Stu[i].homead << '\t';
cout << a.Stu[i].academy << '\t' << a.Stu[i].telephone << '\t' << a.Stu[i].number << endl;
}
else if (t == 2){
cout << a.Stu[i].Name << endl;
cout << "专业成绩:" << a.Stu[i].major << endl;
cout << "高数成绩:" << a.Stu[i].math << endl;
cout << "英语成绩:" << a.Stu[i].english << endl;
}
else exit(0);
}
}
}
if (i >= a.Size) cout << "\t\t\t【系统提示】未查到此人" << endl;
break; }
case 2:{teacher b;
int q;
int m;
b.inputinfo();
q = b.findjs();
if (q == 1){
teacherunlock(); cout << endl;
while (1){
cout << "\t\t\t |1.录入学生信息 2.修改学生成绩 3.学生成绩排序 4.查询学生成绩 5.成绩折线图 6.退出|\n\n" << endl;
cin >> m;
switch (m){
case 1:{a.lr(); break; }
case 2:{a.rewrite(); break; }
case 3:{a.paixu(); break; }
case 4:{a.xmcx(10); break; }
case 5:{a.tumenu(); break; }
case 6:{exit(0); break; }
}
}
}
else cout << "\t\t\t【系统提示】信息有误,重新输入" << endl;
break; }
case 3:{ User user;
int chose;
cout << endl;
cout << "\t\t\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n";
cout << "\t\t\t┃ 1.注 册 2.登 录 ┃\t\n";
cout << "\t\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n";
cout << "\t\t\t【系统提示】请输入你的选择:";
cin >> chose;
if (chose > 2 || chose < -1)
{
cout << "\t\t\t【系统提示】输入格式错误,请重新输入:";
cin >> chose;
}
switch (chose)
{
case 1:user.Registers(); break;
case 2:user.Login(); break;
}
showmenu();//用户权限菜单函数
cout << "请选择相应序号:" << endl;
int flag, t; cin >> flag;
userunlock();
cout << endl;
switch (flag){
case 0:{t = 0; break; }
case 1:{ int hh; cout << "录入方式选择:" << endl;
cout << "\t\t\t | 1. 批量录入学生信息\t\t2.单个学生信息录入\t\t |\n\n" << endl;
cin >> hh;
switch (hh){
case 1: a.inputinformation(); break;
case 2:a.lr(); break;
}
break; }
case 2: {int hh;
cout << "查询方式选择:" << endl;
cout << "\t\t\t | 1. 姓名查询\t\t2.班级查询\t\t3.学号查询\t\t |\n\n" << endl;
cout << "\t\t\t | 4. 课程查询\t\t5.不及格查询\t\t6.通讯公司\t\t |\n\n" << endl;
cin >> hh;
switch (hh){
case 1: {a.xmcx(); break; }
case 2: {a.bjcx(); break; }
case 3: {a.xhcx(); break; }
case 4:{a.dkcx(); break; }
case 5: {a.bjgcx(); break; }
case 6:{a.sjcx(); break; }
}
break; }
case 3:{int plas;
cout << "\t\t\t | 1. 姓名修改成绩\t\t2.学号修改成绩\t\t3.批量修改\t\t |\n\n" << endl;
cout << "修改方式及内容选择:" << endl;
cin >> plas;
switch (plas){
case 1: { a.rewrite(); break; }
case 2: {a.rewrite1(); break; }
case 3:{a.xg(); break; }
}
break; }
}
}
}
}
【无标题】大二教务系统全部
于 2022-04-12 18:51:04 首次发布