本文实例为大家分享了C++实现学校运动会管理系统的具体代码,供大家参考,具体内容如下
#include
#include
#include
using namespace std;
void fun1()
{ cout<
cout<
cout<
cout<
cout<
cout<
cout<
cout<
cout<
cout<
cout<
cout<
cout<
}
class Match
{
public:
Match *next;//为创建链表做准备
int number; //比赛项目编号
char call[10]; //比赛项目名称
char time[10]; //比赛时间
char place[20]; //比赛地点
friend void input1();
};
void input1()
{ ofstream fout("e:\\比赛项目.dat",ios::app);
char ch;
Match a;
do
{ cout<
cin>>a.number>>a.call>>a.place>>a.time;
a.next=NULL;
fout.write((char *)&a,sizeof(Match));
cout<
cin>>ch;
}while(ch=='y'||ch=='Y');
fout.close();
}
Match *head1;
void creat()
{ head1=NULL;
Match *p,*q=head1;
ifstream fin("e:\\比赛项目.dat",ios::in);
if(!fin)
{ cout<
}
p=new Match;
fin.read((char*)p,sizeof(Match));
while(!fin.eof())
{ if(head1==NULL) head1=p;
else
q->next=p;
q=p;
p=new Match;
fin.read((char*)p,sizeof(Match));
}
fin.close();
}
int change1() //对比赛项目相关信息修改
{
cout<
creat();
Match *p1;
p1=head1;
cout<
int number1; //要修改的比赛项目编号
int sign=0; //设置的标记变量
cin>>number1;
while(p1!=NULL)
{ if(p1->number==number1) {sign=1;break;}
p1= p1->next;
}
if (sign==0)
cout<
else
{
cout<
cout<
cout<
cout<
cout<
cout<
int a;
int nu; //新的整形数据
char info[20]; //新的字符数组
cin>>a;
switch(a)
{
case 1:cout<
cin>>nu;
p1->number=nu;
cout<
break;
case 2:cout<
cin>>info;
strcpy(p1->call,info);
cout<
break;
case 3:cout<
cin>>info;
strcpy(p1->time,info);
cout<
break;
case 4:cout<
cin>>info;
strcpy(p1->place,info);
cout<
break;
}
ofstream fout("e:\\比赛项目.dat",ios::out);
p1=head1;
while(p1!=NULL)
{
fout.write((char*)p1,sizeof(Match));
p1=p1->next;
}
fout.close();
}
return 0;
}
int delete1() //对比赛项目相关信息进行删除
{ creat();
Match *p1,*p2;
p2=p1=head1;
cout<
cout<
cout<
cout<
int n;
cin>>n;
int num,flag=0;
char cal[10];
switch(n)
{case 1: cin>>num;
while(p1!=NULL)
{ if(p1->number==num) {flag=1;break;}
p2=p1;
p1= p1->next;
}
if (flag==0)
cout<
else
p2->next=p1->next;
case 2: cin>>cal;
while(p1!=NULL)
{ if(!strc