C++实现校园运动会报名系统

本文为大家分享了C++实现校园运动会报名系统的具体代码,供大家参考,具体内容如下

main.cpp

#include "Campus.h"#include "List.h"/*校园运功会报名系统  实现报名信息录入 和 展示 *//*    信息录入  1 . 建立运动会项目信息表 , 字段包括 , 项目编号 , 项目名称 , 学生姓名 ,院系 ,班级 ,性别    年龄,参赛时间 ,报名时间 ;  2  完成运动会报名信息新增页 ,  3 查询报名 情况      4管理员系统可以更改报名截止时间 和 运动员的可想更改 (可以改成英文版和中文版切换)  */int main(){  ShowPage();  return 0;}

Campush.h

#ifndef CAMPUS_H#define CAMPUS_H#include "List.h"void ShowPage();void MenuChoose(); // 主菜单void Apply_System();// 报名系统void Show_Apply_System(); // 报名系统页面void Apply_Information_Query();// 信息查询void show_in_AdSYstem();// 管理员展示页面void Administrator_System();// 管理员系统;void Athlete_Information(); // 运动员信息查询void Sport_item_sign(); // 运动项目报名void printList_new(Message &M); // 打印带有项目的信息bool Judge_IF_sign(char *) ; // 判断学生是否报名项目void Point_Base_Me(char *Temp); // 打印运动员信息void AD_Menu(); // 管理员系统菜单void Manage_system();// 管理员系统void Log_Administrator();void AD_Menu2();void Cancel_signup();void Revise_Data();void Enter_Adsystem(); // 管理员登录bool Judge_IF_Past_due();// 判断是否逾期;extern void Go_back1(); // 返回第一页extern void Go_back2(); // 返回第二页;extern void Go_back3();extern void Go_back4();#endif // CAMPUS_H

List.cpp

#include "List.h"#include "Campus.h"#include <iostream>#include <cstdio>#include <cstdlib>#include <windows.h>#include <io.h>using namespace std ;void Gettime_f(int &year ,int &month ,int &day ,int &hours ,int &minutes ,int &second ){ /*获取本地时间 */ time_t now ; struct tm *tm_now ; time(&now) ; tm_now = localtime(&now) ; year = tm_now->tm_year+1900 ; month = tm_now->tm_mon+1 ; day = tm_now->tm_mday ; hours = tm_now->tm_hour ; minutes = tm_now->tm_min ; second = tm_now->tm_sec ; return ;}Status List::CreatList(LinkList &L,int n){ // 创建链表; int i ; time_t now ; struct tm *tm_now ; time(&now) ; tm_now = localtime(&now) ; LinkList p ; LinkList head =NULL ; LinkList Last ; for(i=0 ; i<n ;i++) { system("cls"); cout<<"请输入第 " <<i+1<<"名学生信息 : "<<endl; p = (LinkList )malloc(sizeof(LNode)) ; if(p==NULL) {  cout<<"CreatList fail "<<endl;  exit(ERROR) ; } cout<<"姓名"<<" " ; cin>> p->data.name ; cout<<endl; cout<<"学号"<<" :"; cin >>p->data.IDcard ; cout<<endl; cout<<"性别"<<" :" ; cin>> p->data.gender; cout<<endl; cout<<"年龄"<<" :" ; cin>> p->data.age ; cout<<endl; cout<<"学院"<<" :" ; cin>> p->data.Institute ; cout<<endl; cout<<"班级"<<" :" ; cin>> p->data.Class; cout<<endl; /* strcpy(p->data.sport_it1,"000"); strcpy(p->data.sport_it2,"000");*/  p->next = NULL ;  Gettime_f(p->data.Join_time.year ,p->data.Join_time.month ,p->data.Join_time.day ,p->data.Join_time.hours  ,p->data.Join_time.minutes ,p->data.Join_time.second) ;  if(head == NULL)  head = p ; else {  Last->next = p ; } Last = p ;   } L = head ; FILE_Memory(L);  cout<< " 信息录用成功"<< endl; return OK ;} Status List::GetElem(LinkList &L,int i ,Message &e){ /*   条件:线性表存在;    操作结果 : 如果 i 合法 得到线性表第i位置上的元素,反馈给e ; L 是不带头结点的; */ LinkList p ; if(!L) { cout<<" GetElem failed"<<endl; exit(ERROR) ; } p = L ; int k = 1 ; while(p) { if(k>=i) break ; ++k; p = p->next ;  } if(!p || k>i) { cout<<"没找到"<<endl; e.age = UNFOUND ; e.gender = 'F' ; strcpy(e.Class,""); strcpy(e.Institute,""); strcpy(e.name,"");  } e = p->data ; return OK ;} Status List::printList(LinkList &L ){ /* 打印线性表 */ LinkList p = L ; while(p) { cout<<"姓名 : " <<p->data.name <<endl; cout<<"学号 : " <<p->data.IDcard <<endl; cout<<"性别 : "<<p->data.gender<<endl; cout<<"年龄 : "<<p->data.age<<endl; cout<<"学院 : "<<p->data.Institute<<endl; cout<<"班级 : "<<p->data.Class<<endl; cout<<"报名时间 : "<<p->data.Join_time.year<<"-"<<p->data.Join_time.month<<"-"<< p->data.Join_time.day <<" "<<p->data.Join_time.hours<<":"<<p->data.Join_time.minutes<<":"<<p->data.Join_time.second<<endl;  p = p->next ; } return OK;} void FILE_Memory(LinkList &L){ FILE *fin ; int res ; char m[MAX] ; char n[MAX] ; char Name[MAX] ; LinkList p = L; if(L==NULL) { cout<<"L is NULL "<<endl; exit(0); } char cpy_Path[MAX] ={'\0'} ; system("cls"); while(p) { //再加一个扫描 , 看是否有重名 ; strcpy(cpy_Path,Path1) ; char T[MAX] ; strcpy(T,strcat( strcat(cpy_Path,p->data.IDcard),".txt")); int Judge = ScanRepetition(T) ;// 扫描是否有重名;  if(Judge == 0) // 存在返回0 {    char ch ;  cout<<"你输入的学号已经被录入或者您输入的学号有误,请不要重复录入. "<<endl;  remove(T); // 操作失败文件删除  Go_back2(); } else {  strcpy(Name,p->data.IDcard ) ;  strcpy(n,strcat(Name, ".txt")); // zhs.txt  strcpy(m,Path1); // D://dos//SportSystem//  strcat(m,n); // D://dos//SportSystem//zhs.txt }  fin = fopen(m,"a+"); if( !fin) {  cout<<"Creat_fin ERROR "<<endl;  exit(0) ; } fprintf(fin,"%s %s %d %c %s %s %d %d %d %d %d %d \n",p->data.IDcard ,p->data.name,p->data.age,p->data.gender ,p->data.Institute, p->data.Class ,p->data.Join_time.year ,p->data.Join_time.month , p->data.Join_time.day ,p->data.Join_time.hours ,p->data.Join_time.minutes, p->data.Join_time.second);  memset(m,'\0',sizeof(m)); memset(n,'\0',sizeof(n)); memset(Name,'\0',sizeof(Name)); memset(cpy_Path,'\0',sizeof(cpy_Path)) ; memset(T,'\0',sizeof(T)); p = p->next ; } fclose(fin); return ;}int ScanRepetition(char *file_name){ // 扫描 ; /* int  access(const  char  *filename,  int  amode); amode参数为0时表示检查文件的存在性,如果文件存在,返回0,不存在,返回-1。 */ return access(file_name,0); }

List.h

#ifndef LIST_H#define LIST_H#include <iostream>#include <cstdlib>#include <direct.h>#include <time.h>#define OK 1#define ERROR 0#define UNFOUND -1#define Path1 "D:\\dos\\SportSystem\\"using namespace std ;const int MAX = 200 ;typedef int Status ;typedef int ElemType ;typedef struct AD_number{ char num[MAX]; char password[MAX]; }AD;typedef struct Person{ char num[MAX] ; char name[MAX] ;}Per;typedef struct Data_location{ int year ; int month ; int day ; int hours ; int minutes ; int second ;}Data;typedef struct Athlete_Message{ char IDcard[MAX] ; char name[MAX] ; // 姓名 char gender ; // 性别 int age ; char Institute[MAX] ; // 学院 char Class[MAX] ;// 班级; Data Join_time; // char sport_it1[MAX] ; // 项目一 char sport_it2[MAX] ; // 项目二}Message;typedef struct node{ Message data ; struct node *next ;}LNode, *LinkList;class List{  public:    Status CreatList(LinkList &L,int n) ;    Status GetElem(LinkList &L,int i ,Message &e) ;    Status printList(LinkList &L ) ;    private : Message e ;};int ScanRepetition(char * );void FILE_Memory(LinkList &L);void Srearch_city_fiction(FILE *fp);void Gettime_f(int &year ,int &month ,int &day ,int &hours ,int &minutes ,int &second );#endif // LIST_H

Campus.cpp

#include "Campus.h"#include "List.h"#include <windows.h>#define Path2 "D:\\dos\\Administrator\\"void ShowPage(){ cout<<endl<<endl;  cout<<"\t\t\t  ***********************************"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t校 园 运 动 会 报 名 系 统  *"<<endl ;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ☆"<<" 1 报名系统进入  ☆  *"<<endl; cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ☆"<<" 2 报名信息查询  ☆  *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ☆"<<" 3 运动员信息   ☆  *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ☆"<<" 4 退出系统    ☆  *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ☆"<<" 0 管理员系统   ☆  *"<<endl;   cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  ***********************************"<<endl;  MenuChoose();  return ;}void MenuChoose(){  int num ;  cout<<endl;  cout<<"========================================================================"<<endl;  cout<<"功能选择"<<endl;  if(scanf("%d",&num)) // 正常输入  {    switch (num)    {      case 1:        {            system("cls");// 清屏转换下一级功能;   Show_Apply_System();           }        break ;      case 2:        {         Apply_Information_Query();          }        break ;      case 3:        {   Athlete_Information();           }        break ;  case 0:  {   Administrator_System();     }  break ;  case 4:  {   exit(0);     }      default :        {          cout<<"ERORR"<<endl;          exit(ERROR);        }    }   }   return ;}void Apply_System(){ /*报名系统 */ FILE *fp ; List a ; // 对象 LinkList L ; // int i ,n ; char ch1,ch2 ; char ch3 ; cout<<"个数"<<endl; cin >> n ; a.CreatList(L,n); cout<<" 身份信息确认 "<<"[y/n]"<<" "; cin >>ch1 ; if(ch1=='y') { cout<<" 确认成功 "<<endl; Sleep(1); } cout<<" 身份信息查看 "<<"[y/n]"<<" "; cin >>ch2 ; if(ch2=='y') { a.printList(L); Sleep(500); } Go_back1();   return ;}void Show_Apply_System(){ int index ; cout<<endl<<endl<<endl;  cout<<"\t\t\t  ***********************************"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t   报 名 系 统      *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ◎"<<" 1 学生信息录入   ◎  *"<<endl; cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ◎"<<" 2 运动项目报名   ◎  *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ◎"<<" 3 返回上一页    ◎  *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  ***********************************"<<endl; cout<<"请选择"<<endl; cin >>index ; if(index == 1) { Apply_System();// 录用信息 } else if(index ==2 ) { LinkList L ; cout<<"运动项目报名"<<endl; Sport_item_sign();  } else if( index == 3) { system("cls"); ShowPage(); } else { Go_back2(); }  return ;}void Sport_item_sign(){ // 首先 参看运动会参赛注意事项; char ch ; char ih ; int it1,it2 ; char Id[MAX] ; char Cpy_path1[MAX] ; Message M ,Stu; Data d ; FILE *fp = fopen("Data.txt","r"); cout<<"注意报名截止时间 : "; if(!fp) { exit(0); }  fscanf(fp ,"%d%d%d%d%d%d",&d.year,&d.month,&d.day,&d.hours ,&d.minutes ,&d.second); printf("[ %d -%d -%d  %d:%d: %d  ]\n",d.year,d.month,d.day,d.hours ,d.minutes ,d.second); cout<<endl; if(Judge_IF_Past_due() == true ) { // 时间过期; cout<<" 报名时间已经截止 "; Go_back2(); } else { cout<<"输入你的学生证号 :  "; cin >>Id ; strcpy(Cpy_path1,Path1) ; strcat(Cpy_path1,Id); strcat(Cpy_path1,".txt"); if(ScanRepetition(Cpy_path1) == -1) {  cout<<"没有该学生信息"<<endl;  Go_back1(); }  if(ScanRepetition(Cpy_path1)==0 && Judge_IF_sign(Cpy_path1)) {  cout<<"该生已经报名,请勿重复报名"<<endl;  Go_back2(); } FILE *fIDCARD = fopen(Cpy_path1 ,"a+"); // 添加运动项目 if(!fIDCARD) {  cout<<"open the file "<<endl;  exit(0) ; } /*识别性别*/  rewind(fIDCARD); fscanf(fIDCARD,"%s %s %d %c %s %s %d %d %d %d %d %d ",Stu.IDcard ,Stu.name ,&Stu.age ,&Stu.gender ,Stu.Institute ,Stu.Class,  &Stu.Join_time.year ,&Stu.Join_time.month ,&Stu.Join_time.day ,&Stu.Join_time.hours ,&Stu.Join_time.minutes,&Stu.Join_time.second );  system("cls"); FILE *SPORT_IN_FILE = fopen("SPORT.txt","r"); if(!SPORT_IN_FILE) {  cout<<"SPORT_IN_FILE open ERROR"<<endl;  exit(0); } ch = fgetc(SPORT_IN_FILE); while(!feof(SPORT_IN_FILE)) {  putchar(ch);  ch = fgetc(SPORT_IN_FILE);  Sleep(5); } fclose(SPORT_IN_FILE); system("pause"); system("cls"); cout<<endl <<endl ; if (Stu.gender == 'm')// 如果是男的 { Per p[MAX] ; // num ; // name ; char t1[MAX] ,t2[MAX] ; FILE *sport = fopen("sportitemM.txt","r"); if(!sport) {  cout<<"sportitemM open ERROR"<<endl;  exit(0); } ih = fgetc(sport); while(!feof(sport)) {  putchar(ih);  ih = fgetc(sport);  Sleep(10); } fclose(sport); FILE *fin = fopen("M.txt","r");  cout<<endl; cout<<"选择参加项目"<<endl; cout<<"每名运动员可任意选择两种项目 (选一种的选择000)"<<endl; //cin >> M.sport_it1 >> M.sport_it2 ; cin >> t1 >> t2 ; int i = 0 ; int flag1 , flag2 ; while(!feof(fin)) {    fscanf(fin , "%s %s",p[i].num ,p[i].name);  i++ ; } int j = 0 ; while(j<=i) {  if (strcmp(t1 , p[j].num)==0)  {  flag1 = j ;   }  if (strcmp(t2 , p[j].num)==0)  {  flag2 = j ;  }  j++ ; }  strcpy(M.sport_it1 , p[flag1].name); strcpy(M.sport_it2 , p[flag2].name); fprintf(fIDCARD,"%s %s",M.sport_it1 ,M.sport_it2); rewind(fIDCARD); fscanf(fIDCARD,"%s %s %d %c %s %s %d %d %d %d %d %d %s %s",M.IDcard ,M.name ,&M.age ,&M.gender ,M.Institute ,M.Class,  &M.Join_time.year ,&M.Join_time.month ,&M.Join_time.day ,&M.Join_time.hours ,&M.Join_time.minutes,&M.Join_time.second, M.sport_it1,M.sport_it2);  cout<<"选择成功"<<endl; printList_new(M); fclose(fIDCARD); Sleep(500); Go_back1(); } else if (Stu.gender == 'f') { Per p[MAX] ; char t1[MAX] ,t2[MAX] ; FILE *sport = fopen("sportitemF.txt","r"); if(!sport) {  cout<<"sportitemM open ERROR"<<endl;  exit(0); } ih = fgetc(sport); while(!feof(sport)) {  putchar(ih);  ih = fgetc(sport);  Sleep(10); } fclose(sport); FILE *fin = fopen("F.txt","r");  cout<<endl; cout<<"选择参加项目"<<endl; cout<<"每名运动员可任意选择两种项目 (选一种的选择000)"<<endl;  cin >> t1 >> t2 ; int i = 0 ; int flag1 , flag2 ; while(!feof(fin)) {   fscanf(fin , "%s %s",p[i].num ,p[i].name);  if (strcmp(t1 , p[i].num)==0)  {  flag1 = i ;   }  if (strcmp(t2 , p[i].num)==0)  {  flag2 = i ;  }  i++ ;  } strcpy(M.sport_it1 , p[flag1].name); strcpy(M.sport_it2 , p[flag2].name); fprintf(fIDCARD,"%s %s",M.sport_it1 ,M.sport_it2); rewind(fIDCARD); fscanf(fIDCARD,"%s %s %d %c %s %s %d %d %d %d %d %d %s %s",M.IDcard ,M.name ,&M.age ,&M.gender ,M.Institute ,M.Class,  &M.Join_time.year ,&M.Join_time.month ,&M.Join_time.day ,&M.Join_time.hours ,&M.Join_time.minutes,&M.Join_time.second, M.sport_it1,M.sport_it2);  cout<<"选择成功"<<endl; printList_new(M); fclose(fIDCARD); Sleep(500); Go_back1();  }  }}  void Apply_Information_Query(){ // 报名信息查询 ; int i ; char id_register[MAX] ; char Temp[MAX]; system("cls"); cout <<"请输入学号 :"<<"  " ; cin>>id_register ; strcpy(Temp,Path1); strcat(id_register,".txt"); strcat(Temp,id_register); if(ScanRepetition(Temp)== -1 ) { cout<<"没有该生的相关信息!"<<endl; Go_back1(); } if(Judge_IF_sign(Temp)== false) { cout<<"状态 : 未报名"<<endl; } else cout<<"状态 : 已报名"<<endl;  Go_back1();  return ;}void Athlete_Information(){ int i ; char id_register[MAX] ; char Temp[MAX]; system("cls"); cout <<"请输入学号 :"<<"  " ; cin>>id_register ; strcpy(Temp,Path1); strcat(id_register,".txt"); strcat(Temp,id_register); if(ScanRepetition(Temp)== -1) { cout<<"没有该生的相关信息!"<<endl; Go_back1(); } if(Judge_IF_sign(Temp)) { Point_Base_Me(Temp); Go_back1(); } else { cout<<"还没报名哦 ,请现在报名才能查看哦 !"<<endl; Go_back1(); }  return ;}bool Judge_IF_sign(char *Path){ // 判断学生是否已报名项目; bool flag = false ; char Temp[MAX] ; int count = 0; FILE *fp = fopen(Path ,"r") ; if(!fp) { cout<<"该生没有录入信息"<<endl; exit(0) ; } while(!feof(fp)) { count +=fscanf(fp,"%s",Temp);  } if (count == 14)// 如果已经报名; flag = true ; return flag ;}void Go_back1(){ char ch ; cout<<" 返回主页面  "<<" [y/n] "; cin >>ch ; if(ch=='y') { system("cls"); ShowPage(); } else { cout<<"服务器错误00044xx"<<endl; exit(0); } return ;}void Go_back2(){ char ch ; cout<<" 返回上一级  "<<" [y/n] "; cin >>ch ; if(ch=='y') { system("cls"); Show_Apply_System(); } else { cout<<"服务器错误00044xx"<<endl; exit(0); } return ;  }void Go_back3(){  // 返回管理系统上一级; char ch ; cout<<" 返回上一级  "<<" [y/n] "; cin >>ch ; if(ch=='y') { system("cls"); show_in_AdSYstem(); } else { cout<<"服务器错误00044xx"<<endl; exit(0); }   return ;}void Go_back4(){ char ch ; cout<<" 返回上一级  "<<" [y/n] "; cin >>ch ; if(ch=='y') { system("cls"); Manage_system(); } else { cout<<"服务器错误00044xx"<<endl; exit(0); } return ;}void printList_new(Message &M){  cout<<"姓名 : " <<M.name <<endl; cout<<"学号 : " <<M.IDcard <<endl; cout<<"性别 : "<<M.gender<<endl; cout<<"年龄 : "<<M.age<<endl; cout<<"学院 : "<<M.Institute<<endl; cout<<"班级 : "<<M.Class<<endl; cout<<"报名项目 : "<<M.sport_it1 <<" "<<M.sport_it2 <<endl; cout<<"报名时间 : "<<M.Join_time.year<<"-"<<M.Join_time.month<<"-"<< M.Join_time.day <<" "<<M.Join_time.hours<<":"<<M.Join_time.minutes<<":"<<M.Join_time.second<<endl;  return ;}void Point_Base_Me(char *Temp){ FILE *fp = fopen(Temp,"r"); Message M ;  fscanf(fp,"%s %s %d %c %s %s %d %d %d %d %d %d %s %s",M.IDcard ,M.name ,&M.age ,&M.gender ,M.Institute ,M.Class, &M.Join_time.year ,&M.Join_time.month ,&M.Join_time.day ,&M.Join_time.hours ,&M.Join_time.minutes,&M.Join_time.second, M.sport_it1,M.sport_it2); printList_new(M); Go_back1(); return ;}void Administrator_System(){ // 管理员 ; // 加一个 管理员登录 ; Enter_Adsystem(); }void show_in_AdSYstem(){ /* cout<<"您已进入管理员系统"<< endl; cout<<"请输入管理员账号和密码"<<endl;*/ system("cls"); cout<<endl<<endl;  cout<<"\t\t\t  ***********************************"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t  管 理 员 系 统      *"<<endl ;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ☆"<<" 1 账号注册    ☆   *"<<endl; cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ☆"<<" 2 管理系统    ☆   *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ☆"<<" 3 返回上一页   ☆   *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  ***********************************"<<endl; AD_Menu(); return ;}void AD_Menu(){   int num ;  cout<<endl;  cout<<"========================================================================"<<endl;  cout<<"功能选择"<<endl;  if(scanf("%d",&num)) // 正常输入  {    switch (num)    {      case 1:        {   Log_Administrator();  }        break ;      case 2:        {         Manage_system();                }        break ;  case 3:  {   system("cls");   ShowPage();  }  break ;      default :        {          cout<<"ERORR"<<endl;          exit(ERROR);        }    }   }   return ; }void Log_Administrator(){ // 账号注册 ; FILE *fp ; AD admin ; char Pass_word[MAX] ; char Temp[MAX] ; strcpy(Temp,Path2); cout<<"输入姓名"<<" : "; cin>>admin.num ; strcat(Temp,admin.num); strcat(Temp,".txt"); cout<<endl; cout<<"输入密码"<<" : "; cin>>admin.password ; cout<<endl;OP: cout<<"重复密码"<<" : "; cin>>Pass_word ;  if(strcmp(admin.password,Pass_word) == 0 ) {// 密码正确 并且文件不存在 if(ScanRepetition(Temp)==0) {  cout<<"账户存在"<<endl;  exit(ERROR); } cout<<"注 册 成 功"<<endl; fp = fopen(Temp,"w"); if(!fp) {  cout<<"open Temp failed "<<endl;  exit(ERROR) ; } fprintf(fp,"%s",admin.password);  fclose(fp); Go_back3(); } else { cout<<"密码不一致"<<endl;  goto OP ; }  return ;}void Manage_system(){ system("cls"); cout<<endl<<endl;  cout<<"\t\t\t  ***********************************"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t  管 理 系 统       *"<<endl ;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ☆"<<" 1 运动员报名取消    *"<<endl; cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ☆"<<" 2 修改截止日期     *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *\t"<<" ☆"<<" 3 返回上一页      *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  *                 *"<<endl;  cout<<"\t\t\t  ***********************************"<<endl; AD_Menu2();  return ;}void AD_Menu2(){ int num ;  cout<<endl;  cout<<"========================================================================"<<endl;  cout<<"功能选择"<<endl;  if(scanf("%d",&num)) // 正常输入  {    switch (num)    {      case 1:        {   // 运动员报名取消 删除文件   Cancel_signup();     }        break ;      case 2:        {   // 修改截止日期;   Revise_Data();   Go_back3();        }        break ;  case 3:  {   show_in_AdSYstem();     }       default :        {          cout<<"ERORR"<<endl;          exit(ERROR);        }    }   }   return ;   }void Cancel_signup(){ // 报名取消; // 杀出文件 char id[MAX] ; // char Temp[MAX] ; cout<<" 输入报名取消的运动员学号"<<"  :"; cin >> id ; strcpy(Temp,Path1); strcat(Temp,id); strcat(Temp,".txt"); if(ScanRepetition(Temp) == -1) { cout<<"没有该运动员的信息,报名取消错误"<<endl; exit(0);  } else { remove(Temp); cout<<"删除成功"<<endl;  } Go_back3(); return ; }void Revise_Data(){ // 修改日期 ; FILE *fp = fopen("Data.txt","w"); Data D ; cout<< "输入年份"<<"  : "; cin >> D.year ; cout<<endl; cout<< "输入月份"<<"  : "; cin >> D.month ; cout<<endl; cout<< "输入天数"<<"  : "; cin >> D.day ; cout<<endl; cout<< "输入小时"<<"  : "; cin >> D.hours ; cout<<endl; cout<< "输入分钟"<<"  : "; cin >> D.minutes ; cout<<endl; cout<< "输入秒数"<<"  : "; cin >> D.second ; cout<<endl; fprintf(fp,"%d %d %d %d %d %d",D.year,D.month,D.day ,D.hours ,D.minutes ,D.second); cout<<"修改成功"<<endl; fclose(fp); return ;}void Enter_Adsystem(){ char name[MAX] ; char Temp[MAX] ; char Password[MAX] ; char PW[MAX] ; FILE *fp ; cout <<" 请输入管理员账号名 :  "; cin >> name ; cout<<endl; strcpy(Temp , Path2) ; strcat(Temp , name) ; strcat(Temp , ".txt"); if(ScanRepetition(Temp) == -1) { // 不存在 cout<<" 管理员账号不存在 "<<endl ; exit(0) ; } fp = fopen(Temp , "r") ; if(!fp) { cout<<" open the file failed "<<endl; exit(0) ; } fscanf(fp , "%s",Password); fclose(fp) ; cout <<" 你输入密码验证 "<<" : "; cin >> PW ; if ( strcmp(PW,Password)==0) { int i ;    cout<<"验证成功"<<endl ;     for(i = 1 ; i<= 4 ; i++) {  cout <<i;  Sleep(500) ;  system("cls");  }    show_in_AdSYstem(); } else { cout <<"验证失败"<<endl; Go_back1(); }   return ;}bool Judge_IF_Past_due(){ Message M ; Data D ; // 截止时间 Data SD ; // 当前时间 ;// bool C = true ; // 初始值时过期了 FILE *Dp = fopen("Data.txt","r"); if(!Dp) { exit(0); } fscanf(Dp,"%d%d%d%d%d%d",&D.year,&D.month,&D.day ,&D.hours ,&D.minutes ,&D.second); //printf("截止时间 :%d -%d- %d %d :%d :%d \n",D.year,D.month,D.day ,D.hours ,D.minutes ,D.second); Gettime_f(SD.year ,SD.month ,SD.day ,SD.hours ,SD.minutes ,SD.second); //获取当前时间 printf("当前时间  : [ %d -%d- %d %d :%d :%d  ]\n",SD.year ,SD.month ,SD.day ,SD.hours ,SD.minutes ,SD.second); if( SD.year < D.year ) {// 截止时间 :2019 -5- 47 8 :63 :12// 当前时间 :2018 -7- 11 15 :46 :24  return false ; // 还没截止    } else if (SD.year == D.year && SD.month != D.month) { if(SD.month < D.month) {  return false ; } else if ( SD.month > D.month) {  return true ; }  } else if (SD.year == D.year && SD.month == D.month && SD.day != D.day) { if (SD.day <D.day ) {  // 如果当前天数 小于 截止天数  return false ; } else if ( SD.day > D.day) {  return true ; }   } else if ( SD.year == D.year && SD.month == D.month && SD.day == D.day && SD.hours !=D.hours) {  if (SD.hours <D.hours ) {   return false ; } else if ( SD.hours > D.hours) {  return true ; }  }  }

代码有点多,应该还能改进,路径可以自己改。以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

偶尔因高山流水的美丽停留,

C++实现校园运动会报名系统

相关文章:

你感兴趣的文章:

标签云: