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

2020-01-06 19:41:23王冬梅

本文为大家分享了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] ={''} ;
 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,'',sizeof(m));
 memset(n,'',sizeof(n));
 memset(Name,'',sizeof(Name));
 memset(cpy_Path,'',sizeof(cpy_Path)) ;
 memset(T,'',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);
 
}