火車票的編程
① 火車票上的編號是什麼意思
火車票上的編號意思如下:
1、第一段前6位是車站代碼,7-10位是窗口代碼,11-14位是售票日期。
2、第二段(即15-21位)是車票號碼,應該和左上角的紅色數碼一樣,第三段的最後四位是里程數,其他的應該是加密校驗碼。
3、火車票面上包含多樣信息,包括車型,時間,座位號等。
4、火車票上各種數據的含義 ,前面是車站和窗口代碼後面是發售日期代碼,票號,前面是防偽代碼最後四位里程。
5、火車票票面上包含多種信息,包括乘車區間,車次,開點,座位號,座位等級,票價,發售車站等信息。

(1)火車票的編程擴展閱讀:
注意事項:
不符合乘車條件的處理:
有下列行為時,除按規定補票,核收手續費以外,還必須加收應補票價50%的票款:
1.無票乘車時,補收自乘車站(不能判明時自始發站)起至到站止車票票價。持失效車票乘車按無票處理。
2.持用偽造塗改的車票乘車時,除按無票處理外並送交公安部門處理。
3.持站台票上車並在開車20分鍾後仍不聲明時,按無票處理。
4.持用低等級的車票乘坐高等級列車、鋪位、座席時,補收所乘區間的票價差額。
5.旅客持半價票沒有規定的減價憑證或不符合減價條件時,補收全價票與半價票的差額。
參考資料來源:網路-火車票
② java編程 假設有火車票1000張,創建10個線程模擬10個售票點,每個售票點100毫秒售出一張票。
packagetmp;
publicclassTest{
privatestaticintk=0;//售出票數
privatestaticintcount=1000;//總票數
(intn){
if(k<count){
k++;
System.out.println("第"+n+"售票點售出第"+k+"張票");
returntrue;
}
returnfalse;
}
{//售票點
intn;//售票點編號
publicSellPot(intn){
this.n=n;
}
publicvoidrun(){
while(sell(n)){
try{
Thread.sleep(100);
}catch(InterruptedExceptione){
e.printStackTrace();
}
}
}
}
publicstaticvoidmain(String[]args){
for(inti=1;i<=10;i++){
newSellPot(i).start();
}
}
}
//銀行匯款
publicclassTest2{
privatestaticintk=0;//總匯款
(intm,inti,intn){
k+=m;
System.out.println("第"+n+"個顧客進行第"+(i+1)+"次匯款,銀行接收總匯款"+k);
}
{//售票點
intn;//顧客編號
publicCostum(intn){
this.n=n;
}
publicvoidrun(){
for(inti=0;i<3;i++){
send(100,i,n);//匯款100
try{
Thread.sleep(100);
}catch(InterruptedExceptione){
e.printStackTrace();
}
}
}
}
publicstaticvoidmain(String[]args){
for(inti=1;i<=3;i++){
newCostum(i).start();
}
}
}
③ 火車票下面的編碼代表什麼、怎麼識別火車票真偽
一、火車票下面編碼說明:
1、編碼組成:
火車票最下方,在條形碼的下面有一串數字和字母的組合。
2、其中的含義是:
(1)第1-5位數字表示發售車票的車站代碼,例如京B代碼是21152,京D代碼是12713,清華園,代碼是12710。
(2)第6位代表售票點類型,0表示車站售票處,2表示代售點,所以京A售就對應100010,京AD售對應100012,京B售對應211520,京BD售對應211522,京D售對應127130。
(3)第7-10位數字表示售票窗口的編號。例如清華園售對應1271000001。
(4)第11-14位數字表示出售車票的日期。
(5)最後4位數字是車票上起點站到終點站之間的里程,例如Z85次北京到蘇州是1379公里。
二、識別火車票真偽的方法:
1、先對光看,內有鐵路路徽水印。因為車票都是用內有水印的特殊紙張製成。
2、看是否有刮和改的痕跡。一般犯罪分子常用的手法就是收集廢車票,對其進行挖改.或改日期或座改卧(較少)或買短途挖改成長途。
3、直接向鐵路售票部門查詢或向鐵路公安人員咨詢。一般到問訊處查詢就可以了,工作人員會把車票上的條形碼輸入電腦,一查便知。問訊處一般人也不多,挺方便的.你只要隨便問一個在車站值勤的民警,他們對此經驗豐富,一看便知,也很方便。
4、觀察、手摸判斷法。挖補過的車票,可通過逆光照看和手摸來鑒別,這種假票的製造者,往往是將假票上需要的站名、價格等字體,整個地從其他書、報或廢票上挖下來粘貼上去,因此該字體與整個票面顏色不統一,與票面字樣不一致,只要用手指輕摸票面,便會有凸出感。塗改後的假 票字跡模糊,用手指觸摸會有墨跡較易識別。自行印製的假票,一般紙質較差,有的客票正面底紋斜線模糊、中斷,字跡不規整、不清 楚。
④ c語言進階編程求助「火車票銷售系統」
可以用資料庫系統來做
核心數據結構應該是票,應該包括: 車次 出發日期 出發站 到達站 車廂 座位 是否已出售 購票人 證件號 等欄位屬性
然後所有的操作都可以轉化為 添加、修改票數據
比如買了 現有一張票 0001 {T90、2012-1-1 出發、A 站出發、到達B站、未出售...}
那麼 買票操作就是 票0001的是「否已出售」 「購票人」 "證件號" 做響應修改
如果 只買AB站的一個區間C、D那麼還要修改出發站和到達站 同時添加另外2張新票數據 A到C的哈D到B的票 哈哈有點饒人
添加車次就按照列車的實際情況 一次型的向系統資料庫里添加 若干張票的shu
⑤ c語言編程,購買車票, 乘1-4站3元/位;5-9站4元/位,9站5元一位,求應付款
#include <stdio.h>
int pay(int n);
int main(){
int n;
printf("請輸入乘車站數:\n");
scanf("%d",&n);
printf("需付款%d元\n",pay(n));
return 0;
}
int pay(int n){
if(n>=1 && n<=4){
return 3;
}else if(n>=5 && n<=9){
return 4;
}else if(n==9){
return 5;
}else{
return 999;//輸入有誤
}
}
⑥ 急求「火車票管理系統「編程,採用C或C++實現
你這個工程可不算小,還是自己做吧
⑦ 要求用C語言編程,在Visual C++環境下調試完成火車票信息管理系統。【加急!!!】【最好有注釋。】
這個估計得花人民幣,才有人接手,不是個小活
⑧ C語言編程 車票管理系統
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
# define size 10 struct t_tickets /* 定義結構體 */ {int number; /* 結構體中的申明部分 */ char begin [10]; char start[30]; char loadend[30]; float time; int people; int booked; } t[size]; FILE*fp; struct t_tickets t[size];
void save()
{
int i; if ((fp=fopen("ticket.text","w+"))==NULL)
{
printf("cannot open the file\n");
return;
}
for(i=0;i<size;i++)
if(fwrite(&t[i],sizeof(struct t_tickets),1,fp)!=1)
printf(" file write error\n");
fclose(fp);
}
void input()
{
int i;
printf("----------請錄入班次信息----------\n");
for(i=0;i<size;i++)
{
scanf("%d %s %s %s %f %d %d",&t[i].number,t[i].begin, t[i].start,t[i].loadend,&t[i].time,&t[i].people,&t[i].booked);
save();} }
void output()
{
int i ;
fp=fopen("ticket.text","r");for(i=0;i<size;i++)
{
fread(&t[i],sizeof(struct t_tickets ),1,fp);printf("\n%-4d %-8s %-13s %-13s %-6.1f %-6d %4d\n",t[i].number,t[i].begin, t[i].start,t[i].loadend,t[i].time,t[i].people,t[i].booked);
}
fclose(fp);} void scan(){
int k;int number;
printf("請輸入您想要查詢的班次號:\n");
scanf("%d",&number);
fp=fopen("ticket.text","r");
for(k=0;k<size;k++)
{
fread(&t[k],sizeof(struct t_tickets),1,fp);
if(number==t[k].number)
{ printf("\n 班次 發車時間 起點站 終點站 行車時間 額定載量 已訂票人數 \n");
printf("\n%-4d %-8s %-13s %-13s %-6.1f %-6d %4d\n",t[k].number,t[k].begin, t[k].start,t[k].loadend,t[k].time,t[k].people,t[k].booked);
break;
}
}
if(k>=size)
printf("對不起,沒有您想要查詢的班次,謝謝使用本系統\n");
fclose(fp);
} void check()
{
int i; char loadend[30];
printf("請輸入你想要查詢的終點站的名稱:\n");
scanf("%s",loadend);
fp=fopen("ticket.text","r");
for(i=0;i<size;i++)
{
fread(&t[i],sizeof(struct t_tickets),1,fp);
if(strcmp(loadend,t[i].loadend)==0)
{
printf("\n 班次 發車時間 起點站 終點站 行車時間 額定載量 已訂票人數 \n"); printf("\n%-4d %-8s %-13s %-13s %-6.1f %-6d %4d\n",t[i].number,t[i].begin, t[i].start,t[i].loadend,t[i].time,t[i].people,t[i].booked);
break;
}
}
if(i>=size)
printf("對不起,沒有您想要查詢的班次,謝謝使用本系統!\n");
fclose(fp);
} void book(){
int i;int number;int m;char loadend[30];int ticket=1;
if ((fp=fopen("ticket.text","r"))==NULL)
{
printf("not open the file\n");
return;
}
for(i=0;i<=1;i++)
fread(&t[i],sizeof(struct t_tickets),1,fp);
printf("\n請輸入你想要到達的終點站:\n");
scanf("%s",loadend);
printf("到達此終點站的班次有:\n");
printf("\n 班次 發車時間 起點站 終點站 行車時間 額定載量 已訂票人數 \n");
for(i=0;i<=1;i++)
if(strcmp(loadend,t[i].loadend)==0)
{
ticket=2;
printf("\n 班次 發車時間 起點站 終點站 行車時間 額定載量 已訂票人數 \n");
printf("\n%-4d %-8s %-13s %-13s %-6.1f %-6d %4d\n",t[i].number,t[i].begin, t[i].start,t[i].loadend,t[i].time,t[i].people,t[i].booked);
}
for(i=0;i<=1;i++)
if(strcmp (loadend,t[i].loadend)==0)
if(t[i].booked<t[i].people)
{
ticket=3;
printf("請輸入訂票的張數:\n");
scanf("%d",&m);
for(i=0;i<=size;i++)
if(number=t[i].number); if ((fp=fopen("ticket.text","w"))==NULL)
{
printf("not open the file\n");
return;
}
{
t[i].booked=t[i].booked+m;
if ((fp=fopen("ticket.text","w"))==NULL)
{
printf("not open the file\n");
return;
}
for(i=0;i<=size;i++) fwrite(&t[i],sizeof(struct t_tickets),1,fp); fclose(fp);
printf(" 您訂票成功!謝謝使用本次服務!\n"); }} if(ticket==1)
printf("\n 沒有你查詢的班次,請查詢後在輸入\n");
if(ticket==2)
printf("\n 你想要購買的票以售完,請購買下一班 \n"); fclose(fp); if ((fp=fopen("ticket.text","w"))==NULL)
{
printf("not open the file\n");
return;
} for(i=0;i<=size;i++)
fwrite(&t[i],sizeof(struct t_tickets),1,fp); fclose(fp);
} void rback(){
int number,i,m;if((fp=fopen("ticket.text","r"))==NULL)
{
printf("not open the file\n");
return;
}for(i=0;i<=1;i++)
fread(&t[i],sizeof(struct t_tickets),1,fp);
printf("請輸入退票的班次:\n");
scanf("%d",&number);
printf("請輸入退票的張數:\n");
scanf("%d",&m);
for(i=0;i<=size;i++)
if(number==t[i].number)
{
t[i].booked=t[i].booked-m;
printf("\n 您退票成功!,謝謝\n");}
fclose(fp); if ((fp=fopen("ticket.text","w"))==NULL)
{
printf("not open the file\n");
return;
}
for(i=0;i<=size;i++) fwrite(&t[i],sizeof(struct t_tickets),1,fp); fclose(fp);
}
void over()
{
printf("\n 謝謝您的使用,請按任意鍵結束!\n");
return;
}
void main(){
int b; printf(" 這里是車票管理系統,歡迎你的使用\n");
printf(" 袁宏傑 製作\n");
printf("\n******************************************\n");
printf(" ==== 0,錄入班次信息\n");
printf(" ==== 1,瀏覽信息\n");
printf(" ==== 2,按班次查詢\n");
printf(" ==== 3,按終點站查詢\n");
printf(" ==== 4,預定車票\n");
printf(" ==== 5,退票 \n");
printf(" ==== 6,退出程序\n");
printf("\n******************************************\n");
do{
printf("-----選擇主菜單功能(0~6\n");
scanf("%d",&b);
switch (b)
{
case 0: input(); break;
case 1: output(); break;
case 2: scan(); break;
case 3: check(); break;
case 4: book(); break;
case 5: rback(); break;
case 6: over(); break;
default: printf(" enter error!\n");
}}while(1);}
⑨ 用java語言編寫一個火車站售票系統,要求如下
這個不難,我正好有個類似的模板,稍微修改下文字,調整下就可以用了。
⑩ c語言車票訂購系統
#include
#include
#include
#include
int shoudsave=0 ;
int count1=0,count2=0,mark=0,mark1=0 ;
/*定義存儲火車信息的結構體*/
struct train
{
char num[10];/*列車號*/
char city[10];/*目的城市*/
char takeoffTime[10];/*發車時間*/
char receiveTime[10];/*到達時間*/
int price;/*票價*/
int bookNum ;/*票數*/
};
/*訂票人的信息*/
struct man
{
char num[10];/*ID*/
char name[10];/*姓名*/
int bookNum ;/*需求的票數*/
};
/*定義火車信息鏈表的結點結構*/
typedef struct node
{
struct train data ;
struct node * next ;
}Node,*Link ;
/*定義訂票人鏈表的結點結構*/
typedef struct people
{
struct man data ;
struct people*next ;
}bookMan,*bookManLink ;
/* 初始界面*/
void printInterface()
{
puts("********************************************************");
puts("* Welcome to use the system of booking tickets *");
puts("********************************************************");
puts("* You can choose the operation: *");
puts("* 1:Insert a train information *");
puts("* 2:Inquire a train information *");
puts("* 3:Book a train ticket *");
puts("* 4:Update the train information *");
puts("* 5:Advice to you about the train *");
puts("* 6:save information to file *");
puts("* 7:quit the system *");
puts("********************************************************");
}
/*添加一個火車信息*/
void InsertTraininfo(Link linkhead)
{
struct node *p,*r,*s ;
char num[10];
r = linkhead ;
s = linkhead->next ;
while(r->next!=NULL)
r=r->next ;
while(1)
{
printf("please input the number of the train(0-return)");
scanf("%s",num);
if(strcmp(num,"0")==0)
break ;
/*判斷是否已經存在*/
while(s)
{
if(strcmp(s->data.num,num)==0)
{
printf("the train '%s'has been born!\n",num);
return ;
}
s = s->next ;
}
p = (struct node*)malloc(sizeof(struct node));
strcpy(p->data.num,num);
printf("Input the city where the train will reach:");
scanf("%s",p->data.city);
printf("Input the time which the train take off:");
scanf("%s",p->data.takeoffTime);
printf("Input the time which the train receive:");
scanf("%s",&p->data.receiveTime);
printf("Input the price of ticket:");
scanf("%d",&p->data.price);
printf("Input the number of booked tickets:");
scanf("%d",&p->data.bookNum);
p->next=NULL ;
r->next=p ;
r=p ;
shoudsave = 1 ;
}
}
/*列印火車票信息*/
void printTrainInfo(struct node*p)
{
puts("\nThe following is the record you want:");
printf(">>number of train: %s\n",p->data.num);
printf(">>city the train will reach: %s\n",p->data.city);
printf(">>the time the train take off: %s\nthe time the train reach:
%s\n",p->data.takeoffTime,p->data.receiveTime);
printf(">>the price of the ticket: %d\n",p->data.price);
printf(">>the number of booked tickets:
%d\n",p->data.bookNum);
}
struct node * Locate1(Link l,char findmess[],char numorcity[])
{
Node*r ;
if(strcmp(numorcity,"num")==0)
{
r=l->next ;
while(r)
{
if(strcmp(r->data.num,findmess)==0)
return r ;
r=r->next ;
}
}
else if(strcmp(numorcity,"city")==0)
{
r=l->next ;
while(r)
{
if(strcmp(r->data.city,findmess)==0)
return r ;
r=r->next ;
}
}
return 0 ;
}
/*查詢火車信息*/
void QueryTrain(Link l)
{
Node *p ;
int sel ;
char str1[5],str2[10];
if(!l->next)
{
printf("There is not any record !");
return ;
}
printf("Choose the way:\n>>1:according to the number of
train;\n>>2:according to the city:\n");
scanf("%d",&sel);
if(sel==1)
{
printf("Input the the number of train:");
scanf("%s",str1);
p=Locate1(l,str1,"num");
if(p)
{
printTrainInfo(p);
}
else
{
mark1=1 ;
printf("\nthe file can't be found!");
}
}
else if(sel==2)
{
printf("Input the city:");
scanf("%s",str2);
p=Locate1(l,str2,"city");
if(p)
{
printTrainInfo(p);
}
else
{
mark1=1 ;
printf("\nthe file can't be found!");
}
}
}
/*訂票子模塊*/
void BookTicket(Link l,bookManLink k)
{
Node*r[10],*p ;
char ch,dem ;
bookMan*v,*h ;
int i=0,t=0 ;
char str[10],str1[10],str2[10];
v=k ;
while(v->next!=NULL)
v=v->next ;
printf("Input the city you want to go: ");
scanf("%s",&str);
p=l->next ;
while(p!=NULL)
{
if(strcmp(p->data.city,str)==0)
{
r[i]=p ;
i++;
}
p=p->next ;
}
printf("\n\nthe number of record have %d\n",i);
for(t=0;t
printTrainInfo(r[t]);
if(i==0)
printf("\n\t\t\tSorry!Can't find the train for you!\n");
else
{
printf("\ndo you want to book it?<1/0>\n");
scanf("%d",&ch);
if(ch == 1)
{
h=(bookMan*)malloc(sizeof(bookMan));
printf("Input your name: ");
scanf("%s",&str1);
strcpy(h->data.name,str1);
printf("Input your id: ");
scanf("%s",&str2);
strcpy(h->data.num,str2);
printf("Input your bookNum: ");
scanf("%d",&dem);
h->data.bookNum=dem ;
h->next=NULL ;
v->next=h ;
v=h ;
printf("\nLucky!you have booked a ticket!");
getch();
shoudsave=1 ;
}
}
}
bookMan*Locate2(bookManLink k,char findmess[])
{
bookMan*r ;
r=k->next ;
while(r)
{
if(strcmp(r->data.num,findmess)==0)
{
mark=1 ;
return r ;
}
r=r->next ;
}
return 0 ;
}
/*修改火車信息*/
void UpdateInfo(Link l)
{
Node*p ;
char findmess[20],ch ;
if(!l->next)
{
printf("\nthere isn't record for you to modify!\n");
return ;
}
else
{
QueryTrain(l);
if(mark1==0)
{
printf("\nDo you want to modify it?\n");
getchar();
scanf("%c",&ch);
if(ch=='y');
{
printf("\nInput the number of the train:");
scanf("%s",findmess);
p=Locate1(l,findmess,"num");
if(p)
{
printf("Input new number of train:");
scanf("%s",&p->data.num);
printf("Input new city the train will reach:");
scanf("%s",&p->data.city);
printf("Input new time the train take off");
scanf("%s",&p->data.takeoffTime);
printf("Input new time the train reach:");
scanf("%s",&p->data.receiveTime);
printf("Input new price of the ticket::");
scanf("%d",&p->data.price);
printf("Input new number of people who have booked ticket:");
scanf("%d",&p->data.bookNum);
printf("\nmodifying record is sucessful!\n");
shoudsave=1 ;
}
else
printf("\t\t\tcan't find the record!");
}
}
else
mark1=0 ;
}
}
/*系統給用戶的提示信息*/
void AdvicedTrains(Link l)
{
Node*r ;
char str[10];
int mar=0 ;
r=l->next ;
printf("Iuput the city you want to go: ");
scanf("%s",str);
while(r)
{
if(strcmp(r->data.city,str)==0&&r->data.bookNum<200)
{
mar=1 ;
printf("\nyou can select the following train!\n");
printf("\n\nplease select the fourth operation to book the ticket!\n");
printTrainInfo(r);
}
r=r->next ;
}
if(mar==0)
printf("\n\t\t\tyou can't book any ticket now!\n");
}
/*保存火車信息*/
void SaveTrainInfo(Link l)
{
FILE*fp ;
Node*p ;
int count=0,flag=1 ;
fp=fopen("c:\\train.txt","wb");
if(fp==NULL)
{
printf("the file can't be opened!");
return ;
}
p=l->next ;
while(p)
{
if(fwrite(p,sizeof(Node),1,fp)==1)
{
p=p->next ;
count++;
}
else
{
flag=0 ;
break ;
}
}
if(flag)
{
printf("the number of the record which have been saved is %d\n",count);
shoudsave=0 ;
}
fclose(fp);
}
/*保存訂票人的信息*/
void SaveBookmanInfo(bookManLink k)
{
FILE*fp ;
bookMan*p ;
int count=0,flag=1 ;
fp=fopen("c:\\man.txt","wb");
if(fp==NULL)
{
printf("the file can't be opened!");
return ;
}
p=k->next ;
while(p)
{
if(fwrite(p,sizeof(bookMan),1,fp)==1)
{
p=p->next ;
count++;
}
else
{
flag=0 ;
break ;
}
}
if(flag)
{
printf("the number of the record which have been saved is %d\n",count);
shoudsave=0 ;
}
fclose(fp);
}
int main()
{
FILE*fp1,*fp2 ;
Node*p,*r ;
char ch1,ch2 ;
Link l ;
bookManLink k ;
bookMan*t,*h ;
int sel ;
l=(Node*)malloc(sizeof(Node));
l->next=NULL ;
r=l ;
k=(bookMan*)malloc(sizeof(bookMan));
k->next=NULL ;
h=k ;
fp1=fopen("c:\\train.txt","ab+");
if((fp1==NULL))
{
printf("can't open the file!");
return 0 ;
}
while(!feof(fp1))
{
p=(Node*)malloc(sizeof(Node));
if(fread(p,sizeof(Node),1,fp1)==1)
{
p->next=NULL ;
r->next=p ;
r=p ;
count1++;
}
}
fclose(fp1);
fp2=fopen("c:\\man.txt","ab+");
if((fp2==NULL))
{
printf("can't open the file!");
return 0 ;
}
while(!feof(fp2))
{
t=(bookMan*)malloc(sizeof(bookMan));
if(fread(t,sizeof(bookMan),1,fp2)==1)
{
t->next=NULL ;
h->next=t ;
h=t ;
count2++;
}
}
fclose(fp2);
while(1)
{
system("cls");
printInterface();
printf("please choose the operation: ");
scanf("%d",&sel);
system("cls");
if(sel==8)
{
if(shoudsave==1)
{
getchar();
printf("\nthe file have been changed!do you want to save it(y/n)?\n");
scanf("%c",&ch1);
if(ch1=='y'||ch1=='Y')
{
SaveBookmanInfo(k);
SaveTrainInfo(l);
}
}
printf("\nThank you!!You are welcome too\n");
break ;
}
switch(sel)
{
case 1 :
InsertTraininfo(l);break ;
case 2 :
QueryTrain(l);break ;
case 3 :
BookTicket(l,k);break ;
case 4 :
UpdateInfo(l);break ;
case 5 :
AdvicedTrains(l);break ;
case 6 :
SaveTrainInfo(l);SaveBookmanInfo(k);break ;
case 7 :
return 0;
}
printf("\nplease press any key to continue.......");
getch();
}
return 0;
}
