⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xitong.h

📁 火车定票系统
💻 H
📖 第 1 页 / 共 2 页
字号:
		int zhuanche=0;
			zhuanche=Zhuanche(shifa,zhongdian);
		    if(zhuanche==0)
			cout<<"对不起,无可转车辆。"<<endl;
		}
	}
}
	
		

		
		

		
		



void TLxitong::TicketOrder()
{  
	char ch,th;
	CheCi * sh;
	cout<<"******请选择订票方式:1 输入车次 2 输入起始和终点选择车次*******"<<endl;
	cout<<"请选择一种方式,输入数字'1'或'2':"<<endl;
	cin>>ch;
	switch(ch)
	{
	case '1':
		{int S=1;
		while(S)
		{
			sh=TNsearch();
			if((sh->Count)==0)cout<<"对不起,此车次车票已售完"<<endl;
			else {(sh->Count)--;S=0;}
		}
		break;
		}
	case '2':
		{
		STsearch();cout<<"若读完以上信息,请选择 1 直达车 2 中转车"<<endl;cin>>th;
		if(th=='1'){sh=TNsearch();(sh->Count)--;}
		if(th=='2')
		{
			sh=TNsearch();(sh->Count)--;
			sh=TNsearch();(sh->Count)--;
		}break;
		}
	}
	cout<<"已为您定票完毕!"<<endl;
}
		
void TLxitong::TicketCancel()
{
	CheCi *sh;char Tm[6];
	for(int tt=0;tt<6;tt++)
		Tm[tt]='\0';
	sh=TNsearch();
	cout<<"请按照示例:09:22输入当前时间:";
	cin>>Tm;
	if((strcmp(Tm,sh->Stime))<0)
	{
		cout<<"可以退票了"<<endl;
		(sh->Count)--;
	}
	else cout<<"超出退票时间限制,对不起,不可以为您退票,请注意以后要尽量提前!"<<endl;
}


////////////////////////////////////
//处理录入的新车次信息即在链表插入一新结点,并将录入的新车次相关信息写进文件checi.txt
void TLxitong::InsertRecord(CheCi * value)
{
        
	    CheCi * pp=tp;
		while(pp->link!=NULL)
			pp=pp->link;
		pp->link=value;
}

Station * chazhandian(CheCi checi[]);
Station * _chazhandian(CheCi checi[]);
Station * pchazhandian(CheCi checi[]);
void TLxitong::ModefyTmessage()
{
	char newdata[200];
	for(int u1=0;u1<200;u1++) newdata[u1]='\0';
	Station *pr=new Station;
	Station * tr;
	FILE * fp;int  u=0;int we;
	int h,i=0,j,r,num;
	char ticket[5];int y=0; int e;int flag=0;
	char ticket1[10];int x=0;
	char money[5];int o=0;	
	int choice=0;
	fp=fopen("checi.txt","a");
	while(choice!=3)
{
	   cout<<"请选择:1 加入新车次;2 修改已有车次;3 退出"<<endl;
       cin>>choice;
	if(choice==1)
	{
		CheCi * p=new CheCi;p->link=NULL;
		cout<<"  以车次-始发站-终点站-发车时间-终点时间-票价-总票量-间停站+到站时间+票价)$这样的顺序输入新车次的信息";
		cout<<"括号前每项以1个'-'分开,括号中每项以'+'分隔,括号后要加结束符'$'"<<endl;
		cout<<"参照此例T182-hankou-haerbin-16:23-19:05-271-5000-(hankou+6:23+0;xuchang+20:35+217;haerbin+19:05+271)$"<<endl;
		cin>>newdata;
     	int t1=fputs(newdata,fp);
		j=1;r=1;h=0;e=0;num=0;
		while(newdata[h]!='$')
		{
			
			if(newdata[h]!='-'&&newdata[h]!='(')
			{
                 
			   switch(j)
			   {
			   case 1:{ p->TrainNum[num]=newdata[h];h++;num++;break;}
			   case 2:{ p->start[num]=newdata[h];h++;num++;break;}
			   case 3:{ p->end[num]=newdata[h];h++;num++;break;}
			   case 4:{ p->Stime[num]=newdata[h];h++;num;break;}
			   case 5:{ p->Etime[num]=newdata[h];h++;num++;break;}
			   case 6:{ ticket[x]=newdata[h];h++;x++;break;}
			   case 7:{ ticket1[y]=newdata[h];h++;y++;break;}
			   }
			}
		  
			else 
			{
				if(newdata[h]=='-'){j++;h++;num=0;}
		        else  { h++;flag=1;}
			}
		   if(newdata[h]!='+'&&newdata[h]!=';'&&newdata[h]!=')'&&flag==1&&newdata[h]!='$')
				  {
					  
					 switch(r)
					{
					 case 1:
					  {
						  pr->staname[e]=newdata[h];e++;h++;break;
					  }
					 case 2:
					  {
						  pr->time[e]=newdata[h];e++;h++;break;
					  }
					 case 3:
					  {
						  money[o]=newdata[h];
						  o++;h++;break;
					  }
					}
				  }
		  
		 else  
		 {
			 if(newdata[h]=='+'){r++;h++;e=0;}
		     if(newdata[h]==';'){tr=new Station;pr->next=tr;pr=tr;r=1;h++;}
             if(newdata[h]==')'){h++;}
			 if(newdata[h]=='$')break;
		 }
		}
        p->Zprice=cti(ticket,x-1);
		p->Count=cti(ticket1,y-1);
		pr->price=cti(money,o-1);
		InsertRecord(p);
		cout<<"加入新车次已成功,退出系统后再进入信息将会被更新"<<endl;
        fclose(fp);
	}
		if(choice==2)
		{
			char modify1[15];char modify2[5];int newNum;
			CheCi * ptr2;int t=0;
			while(t!=9)
		{
		
			cout<<"请输入要修改的车次名"<<endl;
			ptr2=_TNsearch();
			if(ptr2!=NULL)
			{
			cout<<"请选择要修改的数据:1 车次号;2 始发站名;3 终点站名;4 始发时间;5 终点时间;6 全程票价 7 票量;8 经停站;9 退出"<<endl;
			cin>>t;
			
			switch(t)
			{
			 case 1:
				{
					cout<<"请输入新的车次号"<<endl;
					cin>>modify2;
					strcpy(ptr2->TrainNum,modify2);
                    break;
				}
			case 2:
				{
					cout<<"请输入新的始发站名"<<endl;
					cin>>modify1;
					strcpy(ptr2->start,modify1);
				    break;
				}
			case 3:
				{
					cout<<"请输入新的终点站名"<<endl;
					cin>>modify1;
					strcpy(ptr2->end,modify1);
				    break;
				}
			case 4:
				{
					cout<<"请输入始发时间,形式如'16:30'"<<endl;
					cin>>modify2;
					strcpy(ptr2->Stime,modify2);
				    break;
				}
			case 5:
				{
					cout<<"请输入终点时间,形式如'16:30'"<<endl;
					cin>>modify2;
					strcpy(ptr2->Etime,modify2);
					break;
				}
			case 6:
				{
					cout<<"请输入新的票价"<<endl;
					cin>>newNum;
					ptr2->Zprice=newNum;
					break;
				}
			case 7:
				{
					cout<<"请输入新的票余量"<<endl;
					cin>>newNum;
					ptr2->Count=newNum;
					break;
				}
			case 8:
				{
					cout<<"请输入要进行的操作:1 修改已有站点;2:加入新站点;3删除站点;4:退出"<<endl;
                    cin>>we;
				  if(we==1)
					{
                      Station *pt=chazhandian(ptr2);
					  cout<<"请选择要进行的操作:1 修改站名;2 修改时间;3 修改票价"<<endl;
					  int w;
					  cin>>w;
					switch(w)
					{
					case 1:{ cout<<"请输入新的站名"<<endl;cin>>modify1;strcpy(pt->staname,modify1);break;}
					case 2:{ cout<<"请输入新的时间"<<endl;cin>>modify2;strcpy(pt->time,modify2);break;}
					case 3:{ cout<<"请输入新的票价"<<endl;cin>>newNum;pt->price=newNum;break;}
					}
					break;
					}
					if(we==2)
					{
						Station * n=new Station;
					    Station * pp=_chazhandian(ptr2);
                        Station * pp1=pp->next;
						cout<<"请输入新站点的信息,先输入站名,然后时间,最后票价"<<endl;
						cin>>n->staname;
						cin>>n->time;
						cin>>n->price;
						n->next=pp1;
						pp->next=n;
						cout<<"加入站点已成功"<<endl;
						break;
					}
					if(we==3)
					{
						
					Station * qq=pchazhandian(ptr2);
					Station * yy=qq->next->next;
					qq->next=yy;
					cout<<"已成功删除结点"<<endl;
					break;
					}

					if(we==4)
						break;
				}
			case 9:
				break;
			}
				for(int q1=0;q1<15;q1++)
					modify1[q1]='\0';
				for(int q2=0;q2<5;q2++)
					modify2[q2]='\0';
				newNum=0;
				
			}
			
		}
}
		if(choice==3) break;
  }
}		
		
Station * chazhandian(CheCi checi[])
{
	cout<<"请输入要修改的站点名."<<endl;
	char temp[15];
	cin>>temp;
	Station *sta=checi->p;
	int zhaodao =0;
	while (sta!=NULL&&zhaodao==0)
	  {
		if(strcmp(sta->staname,temp)==0)
		{
			cout<<"找到站点"<<sta->staname<<endl;
			zhaodao=1;break;
		}
        sta=sta->next;
	  }
	
	return sta;
}

Station * _chazhandian(CheCi checi[])
{
	cout<<"请输入要在哪一站后加入新站."<<endl;
	char temp[15];
	cin>>temp;
	Station *sta=checi->p;
	int zhaodao =0;
	while (sta!=NULL&&zhaodao==0)
	  {
		if(strcmp(sta->staname,temp)==0)
		{
			cout<<"找到站点"<<sta->staname<<endl;
			zhaodao=1;break;
		}
        sta=sta->next;
	  }
	
	return sta;
}

Station * pchazhandian(CheCi checi[])
{
	cout<<"请输入要在哪一站后删除站点."<<endl;
	char temp[15];
	cin>>temp;
	Station *sta=checi->p;
	int zhaodao =0;
	while (sta!=NULL&&zhaodao==0)
	  {
		if(strcmp(sta->staname,temp)==0)
		{
			cout<<"找到站点"<<sta->staname<<endl;
			zhaodao=1;break;
		}
        sta=sta->next;
	  }
	
	return sta;
}

		

		
		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -