user-0 提问: 【C语言】求帮助看个程序 能运行但是输入数据不弹出结果 

回复:
user: user-1
content: 好长的程序。。

user: user-0
content: a:  printf("\n回到原火车票管理系统:"); 	printf("\n请输入你的选择:"); 	scanf("%d",&x); 	switch(x){ 	   case 1:printf("\n******************************************"); 	          printf("\n*查询功能界面:                           *");               printf("\n*1.按火车出发日期查询*");               printf("\n*2.按车的班次查询*"); 			  printf("\n*3.返回到原火车票系统                    *"); 	          printf("\n******************************************");           b:  printf("\n请输入你的选择:"); 			  scanf("%d",&y); 			  switch(y){ 			    case 1: printf("\n请输入你要查询的售票日期:"); 					    scanf("%s",e); 						searchlist_traindate(myl,e); 						break; 				case 2: printf("\n请输入你要查找的车的班次:"); 					    scanf("%s",d); 						searchlist_trainnum(myl,d); 						break; 				case3: goto a; 					    break; 				default:printf("\n输入错误");} 			  goto b; 			  break; 		case 2:printf("\n请输入你要买的火车票的起点站和终点站:"); 			   scanf("%s%s",f1,f2); 			   if(deletelist_l(myl,f1,f2)){ 				   printf("\n请输出售出一张火车票后的剩余火车票为:"); 			       dataout_l(myl); 			   } 			   break; 		case 3:printf("\n请输入退的这张票的内容\n票号\t班次\t起始站\t终点站\t票价\t出发时间:\n");	   scanf("%d%s%s%s%f%s",&k.ticketnumber,k.trainnum,k.startstation,k.destination,&k.ticketprice,k.traindate); 			   insertlist_l(myl,k); 			   printf("\n请输出退票以后的票的情况:");                dataout_l(myl); 		       break;         case 4:dataout_l(myl); 		       break; 		case 5:w=listcountnum_l(myl); 			   printf("\n******************************************"); 	           printf("\n*排票功能界面:                           *"); 	           printf("\n*1.按票价排票;     *");                printf("\n*2.按车的班次排票;     *"); 			   printf("\n*3.返回到原火车票系统                    *"); 	           printf("\n******************************************"); c:		       printf("\n请输入你的选择:"); 			   scanf("%d",&z); 			   switch(z) 			   	{ 			   case 1:listticketprice_l(myl,w); 				      printf("\n经按票价排票后为:"); 					  dataout_l(myl); 					  break;                case 2:listtrainnum_l(myl,w); 				      printf("\n经按车的班次排票后为:"); 					  dataout_l(myl); 					  break; 			   case 3:goto a;                       default:printf("\n输入错误");} 			          goto c; 			          break;                case 6:printf("\n现有票%d张,且这些票分别为:",listcountnum_l(myl)); 			          dataout_l(myl);                       break; 		       case 7: 		             goto a;                      default:printf("\n输入错误");}                       printf("\n退出程序");                      exit (0); 			    }

user: user-0
content: #include <stdio.h> #include <stdlib.h> #include <malloc.h> #include <string.h> #define OK      1 #define ERROR   0 #define MAX_NUM 10 #define MAX     20 #define MAX1    5  typedef int     status; struct ticket {   long int ticketnumber;            //票号采用长整型     char     trainnum[MAX_NUM];       //车的班次     char     startstation[MAX];       //起始站     char     destination[MAX];        //终点站     float    ticketprice;             //票价     char     traindate[MAX];          //火车出发日期 }ticket[MAX1]; typedef  struct ticket elemtype; typedef struct lnode                 //管理类型重定义 {   elemtype data; 	struct lnode *next; }*linklist,lnode; void save(){FILE *fp; 	int i;     fp=fopen("C:\\ticketrecord.txt","w"); 	if(fp==NULL){printf("\ncannot open file"); 		exit(0); 	}     for(i=0;i<=MAX1-1;i++){ 		if(fwrite(&ticket[i],sizeof(elemtype),1,fp)!=1) 		       printf("\nfile write error"); 	}	 	fclose(fp); } status createlist_l(linklist &L) //生成链表的定义 { int i;   linklist p;   FILE *fp;   fp=fopen("C:\\ticketrecord.txt","r");   if(fp==NULL){printf("\ncannot open file"); 		exit(0);   }   L=(linklist)malloc(sizeof(lnode)); //向内存申请一块占sizeof(lnode)字节的空间，并将这块空间的首地址交给L管理   L->next=NULL;   for(i=MAX1;i>0;i--){p=(linklist)malloc(sizeof(lnode));       if(fread(&p->data,sizeof(elemtype),1,fp)!=1) 	  printf("\nfile read error"); 	  p->next=L->next; 	  L->next=p;   }   fclose(fp);   return OK; } void dataout_l(linklist &L)     //打印火车票 {linklist p; 	p=L->next; 	printf("\n票号\t班次\t起始站\t终点站\t票价\t火车出发日期:"); 	while(p){ 	printf("\n%ld\t%s\t%s\t%s\t%f\t%s",p->data.ticketnumber,p->data.trainnum,p->data.startstation,p->data.destination,p->data.ticketprice,p->data.traindate); 	    printf("\n"); 		p=p->next; 	} } void searchlist_traindate(linklist &L,char e1[])  //按火车出发日期查询 {linklist p; 	int count=0; 	p=L->next; 	while(p){if(strcmp(p->data.traindate,e1)==0){             count++; 			if(count==1) 				printf("\n票号\t班次\t起始站\t终点站\t票价\t火车出发日期\n:");		printf("\n%ld\t%s\t%s\t%s\t%f\t%s",p->data.ticketnumber,p->data.trainnum,p->data.startstation,p->data.destination,p->data.ticketprice,p->data.traindate); 		} 		p=p->next; 	}         if(count==0) 			printf("\n没有找到"); } void searchlist_trainnum(linklist &L,char e3[])  //按班次查询 {linklist p; 	int count=0; 	p=L->next; 	while(p){ 		if(strcmp(p->data.trainnum,e3)==0){ count++; 			if(count==1) 				printf("\n票号\t班次\t起始站\t终点站\t票价\t火车出发日期\n:"); 	printf("\n%ld\t%s\t%s\t%s\t%f\t%s",p->data.ticketnumber,p->data.trainnum,p->data.startstation,p->data.destination,p->data.ticketprice,p->data.traindate); 		}p=p->next;}         if(count==0) 			printf("\n没有找到");} status deletelist_l(linklist L,char k1[],char k2[])  //售票功能 {linklist p,q,r,t,b,c,d; 	char a1[MAX],a2[MAX],a3[MAX_NUM]; 	int count=0,i; 	long int j; 	p=L->next; 	while(p){ 	if(strcmp(p->data.startstation,k1)==0&&strcmp(p->data.destination,k2)==0){ 			count++; 			if(count==1){ 				printf("\n根据你要查找的起点站和终点站有以下这些票:");                 printf("\n票号\t班次\t起始站\t终点站\t票价\t火车出发日期\n:"); 			} 	printf("\n%ld\t%s\t%s\t%s\t%f\t%s",p->data.ticketnumber,p->data.trainnum,p->data.startstation,p->data.destination,p->data.ticketprice,p->data.traindate); 		}p=p->next; 	}if(count==0){printf("\n没有找到你所要查找的票:"); 		return ERROR; 	} 	else{printf("\n根据上述找到的票,请输入你想在找到的这些票中再根据哪种方式那你所需要的票:"); 		printf("\n**********************************");         printf("\n1.按上车时间;     2.按票号;      *"); 	    printf("\n3.按车的班次;                    *");         printf("\n**********************************"); d:		printf("\n请输入你的选择:"); 		scanf("%d",&i); 		switch(i){ 		  case 1:printf("\n请输入你想买火车票的时间范围即时间的下限和上限:"); 			     scanf("%s%s",a1,a2); 			     c=L->next; 				 q=L; while(c){if(strcmp(a1,c->data.traindate)<=0&&strcmp(a2,c->data.traindate)>=0&&strcmp(c->data.startstation,k1)==0&&strcmp(c->data.destination,k2)==0){printf("\n你要买的火车票为:");  printf("\n%ld\t%s\t%s\t%s\t%f\t%s",c->data.ticketnumber,c->data.trainnum,c->data.startstation,c->data.destination,c->data.ticketprice,c->data.traindate); 					   q->next=c->next; 					   free(c);                        return OK;    }    else { q=c; 			c=c->next;}} 				 if(c==NULL) { 					   printf("\n没有你要的票");                        return ERROR; 				 } 			   break; 		case 2:printf("\n请输入你想买的票号:"); 			   scanf("%ld",&j); 			   t=L->next; 			   b=L; while(t){   if(t->data.ticketnumber==j&&strcmp(t->data.startstation,k1)==0&&strcmp(t->data.destination,k2)==0){printf("\n你要买的火车票为:");	  printf("\n%ld\t%s\t%s\t%s\t%f\t%s",t->data.ticketnumber,t->data.trainnum,t->data.startstation,t->data.destination,t->data.ticketprice,t->data.traindate); 					   b->next=t->next; 					   free(t); 					   return OK; 				   }  else { 					   b=t; 					   t=t->next; 				   }} 			   if(t==NULL){printf("\n没有你要的票"); 				       return ERROR; 				} 			   break; 		case 3:printf("\n请输入你要买的火车班次:"); 			   scanf("%s",a3); 			   r=L->next; 			   d=L; 			   while(r){ if(strcmp(r->data.trainnum,a3)==0&&strcmp(r->data.startstation,k1)==0&&strcmp(r->data.destination,k2)==0){printf("\n你要买的火车票为:"); printf("\n%ld\t%s\t%s\t%s\t%f\t%s",r->data.ticketnumber,r->data.trainnum,r->data.startstation,r->data.destination,r->data.ticketprice,r->data.traindate); 					   d->next=r->next; 					   free(r); 					   return OK;                    } 				   else { 					   b=r; 					   r=r->next; 				   } 			   } 			  if(r==NULL) {printf("\n没有你要的票"); 			           return ERROR; 			  } 			 break; 		default:printf("\n输入错误"); 		} 		goto d; 	} }		 status listcountnum_l(linklist &L)   //票数功能 {linklist p; 	int count=0; 	p=L->next; 	while(p){count++; 		p=p->next; 	} 	return count; } status listticketprice_l(linklist &L,int count)  //按票价排票 {int i,j; 	i=count; 	linklist p,t,h,s; 	for(;i>=1;i--){ 		p=L->next; 		t=L; 		h=L; 		if(i==1) continue; 		if(p->data.ticketprice<p->next->data.ticketprice&&i==2) continue;         if(p->data.ticketprice>p->next->data.ticketprice&&i==2){             s=p->next; 			L->next=s;             p->next=s->next; 			s->next=p; 			continue; 		}         p=L->next;         if(p->data.ticketprice>p->next->data.ticketprice) 			s=p; 		else s=p->next; 		p=p->next; 		j=i-1; 		while(p&&j>=1){ 			if(s->data.ticketprice<p->data.ticketprice) 			s=p; 			t=p; 			p=p->next; 			j--; 		} 		if(s==t) continue; 		while(h->next){if(h->next==s){h->next=s->next; 				s->next=t->next; 				t->next=s; 				break; 			} 			else h=h->next; 		} 	} 	return OK; }		 status listtrainnum_l(linklist &L,int count)   //按班次排票 {int i,j; 	i=count; 	linklist p,t,h,s; 	for(;i>=1;i--){p=L->next; 		t=L; 		h=L;         if(i==1) continue; 		if(strcmp(p->data.trainnum,p->next->data.trainnum)<0&&i==2) continue;         if(strcmp(p->data.trainnum,p->next->data.trainnum)>0&&i==2){             s=p->next; 			L->next=s;             p->next=s->next; 			s->next=p; 			continue; 		}         p=L->next;         if(strcmp(p->data.trainnum,p->next->data.trainnum)>0) 			s=p; 		else s=p->next; 		p=p->next; 		j=i-1; 		while(p&&j>=1){if(strcmp(s->data.trainnum,p->data.trainnum)<0) 			s=p; 			t=p; 			p=p->next; 			j--; 		} 		if(s==t) continue; 		while(h->next){ 			if(h->next==s){ 				h->next=s->next; 				s->next=t->next;                 t->next=s; 				break; 			} 			else h=h->next; 		} 	} 	return OK; }		 status insertlist_l(linklist &L,elemtype e)   //退票功能{linklist s,p {     linklist p,t,h,s; 	s=(linklist)malloc(sizeof(lnode)); 	s->data=e; 	p=L->next; 	while(p->next){p=p->next; 	} 	s->next=p->next; 	p->next=s; 	return OK; } void main(){int x,y,w,z,h; 	elemtype k; 	long int j; 	float a; 	char e[MAX],b[MAX],c[MAX],d[MAX_NUM],f1[MAX],f2[MAX]; 	linklist myl;     printf("\n请输入车票数据:"); 	printf("\n票号\t班次\t起始站\t终点站\t票价\t火车出发日期:\n");     for(h=0;h<=MAX1-1;h++){ 	scanf("%d%s%s%s%f%s",&ticket[h].ticketnumber,ticket[h].trainnum,ticket[h].startstation,ticket[h].destination,&ticket[h].ticketprice,ticket[h].traindate); 	} 	save(); 	createlist_l(myl);     printf("\n*************************************"); 	printf("\n*火车票管理系统:                    *");     printf("\n*1.查询功能;     2.售出功能;        *"); 	printf("\n*3.退票功能;     4.打印表功能;      *");     printf("\n*5.排票功能;     6.票数功能         *"); 	printf("\n*7.退出                             *"); 	printf("\n*************************************");