#include<iostream> #include<string.h> #include<string> #include<fstream> #include<conio.h> #include <stdlib.h> #include <stdio.h> using namespace std; #define LL long long int #define mem(a) memset(a,0,sizeof(a)) struct node { LL num;//学号 char mima[100]; char name[100];//姓名 char sex[100];//性别 int year;//年 int month;//月 int day;//日 char edu[100];//学历 //char address[100];//住址 LL tel;//电话 }; void mimaqingchu(int a)//(密码清除) { system("cls"); printf(" 1.管理员 2.用户 请选择 : [1]"); printf(" 请输入密码:"); for(int i=0; i<a; i++) printf("*"); } void zhucemimaqingchu(int a,LL xunhao)//(注册密码清除) { system("cls"); puts("学号:"); printf("xuehao "); // cout<<xunhao<<endl; // cout<<endl; puts("密码:"); for(int i=0; i<a; i++) printf("*"); } void yonghudenglumima(long long int n,int a)//(用户登录密码清除) { system("cls"); printf(" 1.管理员 2.用户 请选择 : [2] "); printf(" 学号:"); //cout<<n; printf("%d ",n); printf(" 密码:"); for(int i=0; i<a; i++) printf("*"); } //class Student //{ //public: // friend class Studentlist; //}; //class Studentlist //{ //public: static int shifoudenglu; node aa[100]; int sum; void menu(); //显示菜单 void face(); void denglu();//登陆 void zhuce();//注册 void add(); //学生信息录入 void show();//显示学生信息在屏幕上 void search(); //学生信息查找 void modify(); //学生信息修改 void dele(); //学生信息删除 void bye();//退出 //}; void face() //外表(完成) { system("color 5E"); //cout<<sum<<endl; ifstream ifs("D:\zz.txt",ios::in|ios_base::binary); if(ifs) { ifs.read(reinterpret_cast<char*>(&sum),sizeof(sum)); ifs.close(); } else { ifs.close(); ofstream ofs("D:\zz.txt",ios::app|ios_base::binary); sum=0; ofs.write(reinterpret_cast<char*>(&sum),sizeof(sum)); ofs.close(); // ifstream eam ifs("D:\zz.txt",ios::in|ios_base::binary); // ifs.read(reinterpret_cast<char*>(&sum),sizeof(sum)); // ifs.close(); //ofs.close(); } puts(" 欢迎进入张晓阳大学学生管理系统"); puts(" **************************************************"); puts(" @ @"); puts(" @ @"); puts(" @ 学生成绩管理系统 @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ 制作人:张晓阳 @"); puts(" @ 日期:2017-05-12 @"); puts(" **************************************************"); printf(" Press [ Enter ] key to continue…… "); getchar(); system("cls"); menu(); } void menu()//显示菜单(完成) { int flag=1,n; while(flag) { system("color 3e"); puts(" 欢迎进入学生学籍管理系统"); puts(" **************************************************"); puts(" @ 1.登陆 @"); puts(" @ 2.注册 @"); puts(" @ 3.添加 @"); puts(" @ 4.显示 @"); puts(" @ 5.查找 @"); puts(" @ 6.修改 @"); puts(" @ 7.删除 @"); puts(" @ 8.退出 @"); puts(" @ ********* @"); puts(" @ * zxy * @"); puts(" @ ********* @"); puts(" **************************************************"); printf(" 请选择服务种类(1-8) : [ ]"); scanf("%d",&n); if(n>=1&&n<=8) { flag=0; } else { system("cls"); printf(" 选择出错,请重新选择。。。 "); } } if(n==1) { system("cls"); denglu(); } else if(n==2) { system("cls"); zhuce(); } else if(n==3) { system("cls"); add(); } else if(n==4) { system("cls"); show(); } else if(n==5) { system("cls"); search(); } else if(n==6) { system("cls"); modify(); } else if(n==7) { system("cls"); dele(); } else if(n==8) { system("cls"); bye(); } } void denglu()//登陆(完成) { int t; system("color 5E"); printf(" 1.管理员 2.用户 请选择 : [ ]"); scanf("%d",&t); char password[20]; if(t==1) { memset(password,0,sizeof(password)); printf(" 请输入密码:"); getchar(); int j=0; while(1) { password[j]=getch(); if(password[j]==' ') break; else if(password[j]==8) { j--; mimaqingchu(j); continue; } printf("*"); j++; } password[j]=' '; if(!strcmp(password,"1715269118")) /*判断密码是否正确*/ { shifoudenglu=1; printf(" 登录成功! "); printf(" Press [ Enter ] key to continue…"); getchar(); system("cls"); menu(); } else if(strcmp(password,"1715269118")) { int biaoji=1; while(biaoji) { system("cls"); printf(" 登陆失败! "); printf(" 1.继续登陆 2.返回出主页面 请选择 : [ ]"); int wc; scanf("%d",&wc); if(wc==1) { biaoji=0; system("cls"); denglu(); } else if(wc==2) { biaoji=0; system("cls"); menu(); } else { system("cls"); } } } } else if(t==2) { ifstream ifs("D:\zxy.txt",ios::in|ios_base::binary); if(ifs) { long long int nn; printf(" 学号:"); scanf("%lld",&nn); printf(" 密码:"); int j=0; while(1) { password[j]=getch(); if(password[j]==' ') break; else if(password[j]==8) { j--; yonghudenglumima(nn,j); continue; } printf("*"); j++; } password[j]=' '; cout<<endl; for(int i=0; i<sum; i++) { ifs.read(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); } ifs.close(); int flag=0; for(int i=0; i<sum; i++) { if(aa[i].num==nn) { if(strcmp(password,aa[i].mima)) { shifoudenglu=1; printf(" 登陆成功! "); printf(" 按 1 返回主页面。。。[ ]"); int flag=1; while(flag) { int t; scanf("%d",&t); if(t==1) { flag=1; system("cls"); menu(); } else { printf(" 按 1 返回主页面。。。[ ]"); } } } } } } } } void zhuce()//注册(完成) { system("color 5E"); ofstream ofs("D:\zxy.txt",ios::app|ios_base::binary); if(!ofs) { cout<<"open error!"<<endl; cout<<"也许你没D盘,哈哈哈。。。"<<endl; getchar(); bye(); } else { puts("学号:"); cin>>aa[sum].num; cout<<endl; puts("密码:"); int j=0; while(1) { aa[sum].mima[j]=getch(); if(aa[sum].mima[j]==' ') break; else if(aa[sum].mima[j]==8) { j--; zhucemimaqingchu(j,aa[sum].num); continue; } printf("*"); j++; } ofs.write(reinterpret_cast<char*>(&aa[sum]),sizeof(aa[sum])); ofs.flush(); ofs.close(); sum++; puts(" 按:1 返回主页面...."); int ppp=1; while(ppp) { int t; scanf("%d",&t); if(t==1) { system("cls"); ppp=0; menu(); } else { system("cls"); puts("学号:"); cout<<aa[sum].num<<endl; cout<<endl; puts("密码:"); for(int i=0; i<j; i++) printf("*"); printf(" "); puts(" 按:1 返回主页面...."); } } } } void add() //学生信息添加函数实现(完成) { system("color 5E"); if(shifoudenglu) { ofstream ofs("D:\zxy.txt",ios::app|ios_base::binary); if(!ofs) { cout<<"open error!"<<endl; cout<<"也许你没D盘,哈哈哈。。。"<<endl; getchar(); bye(); } else { puts("学号:"); cin>>aa[sum].num; cout<<endl; puts("密码:"); int j=0; while(1) { aa[sum].mima[j]=getch(); if(aa[sum].mima[j]==' ') break; else if(aa[sum].mima[j]==8) { j--; zhucemimaqingchu(j,aa[sum].num); continue; } printf("*"); j++; } printf(" 姓名:"); cin>>aa[sum].name; //strcmp(aa[sum].name,a); printf("性别:"); cin>>aa[sum].sex; //strcmp(aa[sum].sex,b); printf("出生年:"); cin>>aa[sum].year; printf("月:"); cin>>aa[sum].month; printf("日:"); cin>>aa[sum].day; printf("学历:"); cin>>aa[sum].edu; //printf("住址:"); //cin>>aa[sum].address; printf("电话:"); cin>>aa[sum].tel; cout<<endl; ofs.write(reinterpret_cast<char*>(&aa[sum]),sizeof(aa[sum])); ofs.flush(); ofs.close(); sum++; puts(" 按:1 返回主页面...."); int ppp=1; while(ppp) { int t; scanf("%d",&t); if(t==1) { system("cls"); ppp=0; menu(); } else { system("cls"); puts("学号:"); cout<<aa[sum].num<<endl; cout<<endl; puts("密码:"); for(int i=0; i<j; i++) printf("*"); printf(" "); puts(" 按:1 返回主页面...."); } } } } else { printf("请先登陆。。。。。。"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } } void show() //学生信息显示函数实现(完成) { system("cls"); system("color 5E"); if(shifoudenglu) { ifstream ifs("D:\zxy.txt",ios::in|ios_base::binary); for(int i=0; i<sum; i++) { ifs.read(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); printf("学号:"); cout<<aa[i].num<<endl; printf("姓名:"); cout<<aa[i].name<<endl; printf("性别:"); cout<<aa[i].sex<<endl; printf("出生年:"); cout<<aa[i].year<<" "; printf("月:"); cout<<aa[i].month<<" "; printf("日:"); cout<<aa[i].day<<endl; printf("学历:"); cout<<aa[i].edu<<endl; //printf("住址:"); //cout<<aa[i].address<<endl; printf("电话:"); cout<<aa[i].tel<<endl; cout<<endl; } ifs.close(); puts(" 按:1 返回主页面...."); int flag=1; while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } else { printf("请先登陆。。。。。。"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } } void search() //学生信息查询函数实现(完成) { system("cls"); system("color 5E"); if(shifoudenglu) { long long int n; printf("请输入你的学号:"); cin>>n; int flagg=0,ii=0; ifstream ifs("D:\zxy.txt",ios::in|ios_base::binary); for(int i=0; i<sum; i++) { ifs.read(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); if(aa[i].num==n) { flagg=1; ii=i; } } ifs.close(); if(flagg==1) { printf("姓名:"); cout<<aa[ii].name<<endl; printf("性别:"); cout<<aa[ii].sex<<endl; printf("出生年:"); cout<<aa[ii].year<<" "; printf("月:"); cout<<aa[ii].month<<" "; printf("日:"); cout<<aa[ii].day<<endl; printf("学历:"); cout<<aa[ii].edu<<endl; //printf("住址:"); //cout<<aa[ii].address<<endl; printf("电话:"); cout<<aa[ii].tel<<endl; cout<<endl; } puts(" 按:1 返回主页面...."); int flag=1; while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } else { printf("请先登陆。。。。。。"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } } void modify() //学生信息修改函数实现(完成) { system("color 5E"); if(shifoudenglu) { ifstream ifs("D:\zxy.txt",ios::in|ios_base::binary); if(ifs) { ifs.close(); long long int n; printf("请输入你的学号:"); cin>>n; int flag=0,jj=0; for(int i=0; i<sum; i++) { ifs.read(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); if(aa[i].num==n) { flag=1; jj=i; } } ifs.close(); printf("密码:"); cin>>aa[jj].mima; printf("姓名:"); cin>>aa[jj].name; //strcmp(aa[jj].name,a); printf("性别:"); cin>>aa[jj].sex; //strcmp(aa[jj].sex,b); printf("出生年:"); cin>>aa[jj].year; printf("月:"); cin>>aa[jj].month; printf("日:"); cin>>aa[jj].day; printf("学历:"); cin>>aa[jj].edu; //printf("住址:"); //cin>>aa[jj].address; printf("电话:"); cin>>aa[jj].tel; cout<<endl; ofstream ofs("D:\zxy.txt",ios::out|ios_base::binary); for(int i=0; i<sum; i++) { ofs.write(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); } printf("修改成功!!!!!!"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } else { cout<<"open error!"<<endl; cout<<"也许你没D盘,哈哈哈。。。"<<endl; getchar(); bye(); } } else { printf("请先登陆。。。。。。"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } } void dele() //学生信息删除函数实现(完成) { system("color 5E"); if(shifoudenglu) { printf("请输入你的学号:"); long long int n; //scanf("%d",&n); cin>>n; ifstream ifs("D:\zxy.txt",ios::in|ios_base::binary); for(int i=0; i<sum; i++) { ifs.read(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); if(aa[i].num==n) { aa[i].num=0; } } ifs.close(); int len=0; for(int i=0; i<sum; i++) { int flag=0; if(aa[i].num==0) { flag=1; } if(!flag) { //strcmp(aa[len].address,aa[i].address); aa[len].day=aa[i].day; strcmp(aa[len].edu,aa[i].edu); strcmp(aa[len].mima,aa[i].mima); aa[len].month=aa[i].month; strcmp(aa[len].name,aa[i].name); aa[len].num=aa[i].num; strcmp(aa[len].sex,aa[i].sex); aa[len].tel=aa[i].tel; aa[len++].year=aa[i].year; } if(i==sum-1) { //memset(aa[i].address,' ',sizeof(aa[i].address)); //aa[i].address=0; aa[i].num=0; aa[i].day=0; mem(aa[i].edu); //aa[i].edu=0; mem(aa[i].mima); //aa[i].mima=0; aa[i].month=0; mem(aa[i].name); //aa[i].name=0; mem(aa[i].sex); //aa[i].sex=0; aa[i].tel=0; //aa[i].tel=0; aa[i].year=0; } } sum--; ofstream ofs("D:\zxy.txt",ios::out|ios_base::binary); for(int i=0; i<sum; i++) { ofs.write(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); } puts(" 删除成功!!!!!!"); puts(" 按:1 返回主页面...."); int flag=1; while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } else { printf("请先登陆。。。。。。"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } } void bye() //退出(完成) { system("color 0F"); ofstream ofs("D:\zz.txt",ios::trunc|ios_base::binary); ofs.write(reinterpret_cast<char*>(&sum),sizeof(sum)); ofs.flush(); ofs.close(); puts(" **************************************************"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ 再见! @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" **************************************************"); exit(0); } int main() { //Studentlist aa; face(); return 0; }
#include<iostream>#include<string.h>#include<string>#include<fstream>#include<conio.h>#include <stdlib.h>#include <stdio.h>using namespace std;#define LL long long int#define mem(a) memset(a,0,sizeof(a))struct node{ LL num;//学号 char mima[100]; char name[100];//姓名 char sex[100];//性别 int year;//年 int month;//月 int day;//日 char edu[100];//学历 //char address[100];//住址 LL tel;//电话};void mimaqingchu(int a)//(密码清除){ system("cls"); printf(" 1.管理员 2.用户 请选择 : [1]"); printf(" 请输入密码:"); for(int i=0; i<a; i++) printf("*");}void zhucemimaqingchu(int a,LL xunhao)//(注册密码清除){ system("cls"); puts("学号:"); cout<<xunhao<<endl; cout<<endl; puts("密码:"); for(int i=0; i<a; i++) printf("*");}void yonghudenglumima(long long int n,int a)//(用户登录密码清除){ system("cls"); printf(" 1.管理员 2.用户 请选择 : [2] "); printf(" 学号:"); cout<<n; printf(" 密码:"); for(int i=0; i<a; i++) printf("*");}class Student{public: friend class Studentlist;};class Studentlist{public: static int shifoudenglu; node aa[100]; int sum; void menu(); //显示菜单 void face(); void denglu();//登陆 void zhuce();//注册 void add(); //学生信息录入 void show();//显示学生信息在屏幕上 void search(); //学生信息查找 void modify(); //学生信息修改 void dele(); //学生信息删除 void bye();//退出};void Studentlist::face() //外表(完成){ system("color 5E"); //cout<<sum<<endl; ifstream ifs("D:\zz.txt",ios::in|ios_base::binary); if(ifs) { ifs.read(reinterpret_cast<char*>(&sum),sizeof(sum)); ifs.close(); } else { ifs.close(); ofstream ofs("D:\zz.txt",ios::app|ios_base::binary); sum=0; ofs.write(reinterpret_cast<char*>(&sum),sizeof(sum)); ofs.close();// ifstream eam ifs("D:\zz.txt",ios::in|ios_base::binary);// ifs.read(reinterpret_cast<char*>(&sum),sizeof(sum));// ifs.close(); //ofs.close(); } puts(" 欢迎进入张晓阳大学学生管理系统"); puts(" **************************************************"); puts(" @ @"); puts(" @ @"); puts(" @ 学生成绩管理系统 @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ 制作人:张晓阳 @"); puts(" @ 日期:2017-05-12 @"); puts(" **************************************************"); printf(" Press [ Enter ] key to continue…… "); getchar(); system("cls"); menu();}void Studentlist::menu()//显示菜单(完成){ int flag=1,n; while(flag) { system("color 3e"); puts(" 欢迎进入学生学籍管理系统"); puts(" **************************************************"); puts(" @ 1.登陆 @"); puts(" @ 2.注册 @"); puts(" @ 3.添加 @"); puts(" @ 4.显示 @"); puts(" @ 5.查找 @"); puts(" @ 6.修改 @"); puts(" @ 7.删除 @"); puts(" @ 8.退出 @"); puts(" @ ********* @"); puts(" @ * zxy * @"); puts(" @ ********* @"); puts(" **************************************************"); printf(" 请选择服务种类(1-8) : [ ]"); scanf("%d",&n); if(n>=1&&n<=8) { flag=0; } else { system("cls"); printf(" 选择出错,请重新选择。。。 "); } } if(n==1) { system("cls"); denglu(); } else if(n==2) { system("cls"); zhuce(); } else if(n==3) { system("cls"); add(); } else if(n==4) { system("cls"); show(); } else if(n==5) { system("cls"); search(); } else if(n==6) { system("cls"); modify(); } else if(n==7) { system("cls"); dele(); } else if(n==8) { system("cls"); bye(); }}void Studentlist::denglu()//登陆(完成){ int t; system("color 5E"); printf(" 1.管理员 2.用户 请选择 : [ ]"); scanf("%d",&t); char password[20]; if(t==1) { memset(password,0,sizeof(password)); printf(" 请输入密码:"); getchar(); int j=0; while(1) { password[j]=getch(); if(password[j]==' ') break; else if(password[j]==8) { j--; mimaqingchu(j); continue; } printf("*"); j++; } password[j]=' '; if(!strcmp(password,"1715269118")) /*判断密码是否正确*/ { shifoudenglu=1; printf(" 登录成功! "); printf(" Press [ Enter ] key to continue…"); getchar(); system("cls"); menu(); } else if(strcmp(password,"1715269118")) { int biaoji=1; while(biaoji) { system("cls"); printf(" 登陆失败! "); printf(" 1.继续登陆 2.返回出主页面 请选择 : [ ]"); int wc; scanf("%d",&wc); if(wc==1) { biaoji=0; system("cls"); denglu(); } else if(wc==2) { biaoji=0; system("cls"); menu(); } else { system("cls"); } } } } else if(t==2) { ifstream ifs("D:\zxy.txt",ios::in|ios_base::binary); if(ifs) { long long int nn; printf(" 学号:"); scanf("%lld",&nn); printf(" 密码:"); int j=0; while(1) { password[j]=getch(); if(password[j]==' ') break; else if(password[j]==8) { j--; yonghudenglumima(nn,j); continue; } printf("*"); j++; } password[j]=' '; cout<<endl; for(int i=0; i<sum; i++) { ifs.read(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); } ifs.close(); int flag=0; for(int i=0; i<sum; i++) { if(aa[i].num==nn) { if(strcmp(password,aa[i].mima)) { shifoudenglu=1; printf(" 登陆成功! "); printf(" 按 1 返回主页面。。。[ ]"); int flag=1; while(flag) { int t; scanf("%d",&t); if(t==1) { flag=1; system("cls"); menu(); } else { printf(" 按 1 返回主页面。。。[ ]"); } } } } } } }}void Studentlist::zhuce()//注册(完成){ system("color 5E"); ofstream ofs("D:\zxy.txt",ios::app|ios_base::binary); if(!ofs) { cout<<"open error!"<<endl; cout<<"也许你没D盘,哈哈哈。。。"<<endl; getchar(); bye(); } else { puts("学号:"); cin>>aa[sum].num; cout<<endl; puts("密码:"); int j=0; while(1) { aa[sum].mima[j]=getch(); if(aa[sum].mima[j]==' ') break; else if(aa[sum].mima[j]==8) { j--; zhucemimaqingchu(j,aa[sum].num); continue; } printf("*"); j++; } ofs.write(reinterpret_cast<char*>(&aa[sum]),sizeof(aa[sum])); ofs.flush(); ofs.close(); sum++; puts(" 按:1 返回主页面...."); int ppp=1; while(ppp) { int t; scanf("%d",&t); if(t==1) { system("cls"); ppp=0; menu(); } else { system("cls"); puts("学号:"); cout<<aa[sum].num<<endl; cout<<endl; puts("密码:"); for(int i=0; i<j; i++) printf("*"); printf(" "); puts(" 按:1 返回主页面...."); } } }}void Studentlist::add() //学生信息添加函数实现(完成){ system("color 5E"); if(shifoudenglu) { ofstream ofs("D:\zxy.txt",ios::app|ios_base::binary); if(!ofs) { cout<<"open error!"<<endl; cout<<"也许你没D盘,哈哈哈。。。"<<endl; getchar(); bye(); } else { puts("学号:"); cin>>aa[sum].num; cout<<endl; puts("密码:"); int j=0; while(1) { aa[sum].mima[j]=getch(); if(aa[sum].mima[j]==' ') break; else if(aa[sum].mima[j]==8) { j--; zhucemimaqingchu(j,aa[sum].num); continue; } printf("*"); j++; } printf(" 姓名:"); cin>>aa[sum].name; //strcmp(aa[sum].name,a); printf("性别:"); cin>>aa[sum].sex; //strcmp(aa[sum].sex,b); printf("出生年:"); cin>>aa[sum].year; printf("月:"); cin>>aa[sum].month; printf("日:"); cin>>aa[sum].day; printf("学历:"); cin>>aa[sum].edu; //printf("住址:"); //cin>>aa[sum].address; printf("电话:"); cin>>aa[sum].tel; cout<<endl; ofs.write(reinterpret_cast<char*>(&aa[sum]),sizeof(aa[sum])); ofs.flush(); ofs.close(); sum++; puts(" 按:1 返回主页面...."); int ppp=1; while(ppp) { int t; scanf("%d",&t); if(t==1) { system("cls"); ppp=0; menu(); } else { system("cls"); puts("学号:"); cout<<aa[sum].num<<endl; cout<<endl; puts("密码:"); for(int i=0; i<j; i++) printf("*"); printf(" "); puts(" 按:1 返回主页面...."); } } } } else { printf("请先登陆。。。。。。"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } }}void Studentlist::show() //学生信息显示函数实现(完成){ system("cls"); system("color 5E"); if(shifoudenglu) { ifstream ifs("D:\zxy.txt",ios::in|ios_base::binary); for(int i=0; i<sum; i++) { ifs.read(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); printf("学号:"); cout<<aa[i].num<<endl; printf("姓名:"); cout<<aa[i].name<<endl; printf("性别:"); cout<<aa[i].sex<<endl; printf("出生年:"); cout<<aa[i].year<<" "; printf("月:"); cout<<aa[i].month<<" "; printf("日:"); cout<<aa[i].day<<endl; printf("学历:"); cout<<aa[i].edu<<endl; //printf("住址:"); //cout<<aa[i].address<<endl; printf("电话:"); cout<<aa[i].tel<<endl; cout<<endl; } ifs.close(); puts(" 按:1 返回主页面...."); int flag=1; while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } else { printf("请先登陆。。。。。。"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } }}void Studentlist::search() //学生信息查询函数实现(完成){ system("cls"); system("color 5E"); if(shifoudenglu) { long long int n; printf("请输入你的学号:"); cin>>n; int flagg=0,ii=0; ifstream ifs("D:\zxy.txt",ios::in|ios_base::binary); for(int i=0; i<sum; i++) { ifs.read(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); if(aa[i].num==n) { flagg=1; ii=i; } } ifs.close(); if(flagg==1) { printf("姓名:"); cout<<aa[ii].name<<endl; printf("性别:"); cout<<aa[ii].sex<<endl; printf("出生年:"); cout<<aa[ii].year<<" "; printf("月:"); cout<<aa[ii].month<<" "; printf("日:"); cout<<aa[ii].day<<endl; printf("学历:"); cout<<aa[ii].edu<<endl; //printf("住址:"); //cout<<aa[ii].address<<endl; printf("电话:"); cout<<aa[ii].tel<<endl; cout<<endl; } puts(" 按:1 返回主页面...."); int flag=1; while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } else { printf("请先登陆。。。。。。"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } }}void Studentlist::modify() //学生信息修改函数实现(完成){ system("color 5E"); if(shifoudenglu) { ifstream ifs("D:\zxy.txt",ios::in|ios_base::binary); if(ifs) { ifs.close(); long long int n; printf("请输入你的学号:"); cin>>n; int flag=0,jj=0; for(int i=0; i<sum; i++) { ifs.read(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); if(aa[i].num==n) { flag=1; jj=i; } } ifs.close(); printf("密码:"); cin>>aa[jj].mima; printf("姓名:"); cin>>aa[jj].name; //strcmp(aa[jj].name,a); printf("性别:"); cin>>aa[jj].sex; //strcmp(aa[jj].sex,b); printf("出生年:"); cin>>aa[jj].year; printf("月:"); cin>>aa[jj].month; printf("日:"); cin>>aa[jj].day; printf("学历:"); cin>>aa[jj].edu; //printf("住址:"); //cin>>aa[jj].address; printf("电话:"); cin>>aa[jj].tel; cout<<endl; ofstream ofs("D:\zxy.txt",ios::out|ios_base::binary); for(int i=0; i<sum; i++) { ofs.write(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); } printf("修改成功!!!!!!"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } else { cout<<"open error!"<<endl; cout<<"也许你没D盘,哈哈哈。。。"<<endl; getchar(); bye(); } } else { printf("请先登陆。。。。。。"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } }}void Studentlist::dele() //学生信息删除函数实现(完成){ system("color 5E"); if(shifoudenglu) { printf("请输入你的学号:"); long long int n; cin>>n; ifstream ifs("D:\zxy.txt",ios::in|ios_base::binary); for(int i=0; i<sum; i++) { ifs.read(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); if(aa[i].num==n) { aa[i].num=0; } } ifs.close(); int len=0; for(int i=0; i<sum; i++) { int flag=0; if(aa[i].num==0) { flag=1; } if(!flag) { //strcmp(aa[len].address,aa[i].address); aa[len].day=aa[i].day; strcmp(aa[len].edu,aa[i].edu); strcmp(aa[len].mima,aa[i].mima); aa[len].month=aa[i].month; strcmp(aa[len].name,aa[i].name); aa[len].num=aa[i].num; strcmp(aa[len].sex,aa[i].sex); aa[len].tel=aa[i].tel; aa[len++].year=aa[i].year; } if(i==sum-1) { //memset(aa[i].address,' ',sizeof(aa[i].address)); //aa[i].address=0; aa[i].num=0; aa[i].day=0; mem(aa[i].edu); //aa[i].edu=0; mem(aa[i].mima); //aa[i].mima=0; aa[i].month=0; mem(aa[i].name); //aa[i].name=0; mem(aa[i].sex); //aa[i].sex=0; aa[i].tel=0; //aa[i].tel=0; aa[i].year=0; } } sum--; ofstream ofs("D:\zxy.txt",ios::out|ios_base::binary); for(int i=0; i<sum; i++) { ofs.write(reinterpret_cast<char*>(&aa[i]),sizeof(aa[i])); } puts(" 删除成功!!!!!!"); puts(" 按:1 返回主页面...."); int flag=1; while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } } else { printf("请先登陆。。。。。。"); puts(" 按:1 返回主页面...."); while(1) { int t; scanf("%d",&t); if(t==1) { system("cls"); menu(); } else { puts("请输入 1 "); } } }}void Studentlist::bye() //退出(完成){ system("color 0F"); ofstream ofs("D:\zz.txt",ios::trunc|ios_base::binary); ofs.write(reinterpret_cast<char*>(&sum),sizeof(sum)); ofs.flush(); ofs.close(); puts(" **************************************************"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ 再见! @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" @ @"); puts(" **************************************************"); exit(0);}int Studentlist::shifoudenglu=0;int main(){ Studentlist aa; aa.face(); return 0;}