求大神帮忙看看 这些错误怎么改
/******头文件(.h)***********/#include <stdio.h> /*I/O函数*/
#include <stdlib.h> /*其它说明*/
#include <string.h> /*字符串函数*/
#include <conio.h> /*屏幕操作函数*/
#include <ctype.h> /*字符操作函数*/
#define N 20
#define Q 40 /*定义常数表示记录数*/
/*定义数据结构*/
/*乘客信息*/
typedef struct
{
char number[10];/*编号*/
char name[10]; /*姓名*/
char id[20]; /*证件号*/
int count; /*订票数*/
char flightname[10];/*乘坐航班号*/
}GUEST;
/*航班信息*/
typedef struct
{char planenumber[10];/*航班号*/
char city1[20]; /*起飞城市*/
char city2[20]; /*抵达城市*/
char time1[20]; /*起飞时间*/
char time2[20]; /*降落时间*/
int room; /*舱位数*/
char price[5]; /*票价*/
char discount[5]; /*折扣*/
GUEST guest[25];
int sit;
}FLY;
/*菜单函数,函数返回值为整数,代表所选的菜单项*/
menu_select()
{
char s[80];
int c;
gotoxy(1,25);/*将光标定为在第25行,第1列*/
printf("press any key enter menu......\n");/*提示压任意键继续*/
getch(); /*读入任意字符*/
clrscr(); /*清屏*/
gotoxy(1,1);
printf(" Welcome to\n\n");
printf(" Tickets Booking System\n\n");
printf(" ********************MENU*********************\n\n");
printf(" 0. Enter flight record\n");
printf(" 1. List the flight information\n");
printf(" 2. Search flightnumber\n");
printf(" 3. Search city\n");
printf(" 4. Book the ticket\n");
printf(" 5. Quit the ticket\n");
printf(" 6. Channge the flight information\n");
printf(" 7. Save the file\n");
printf(" 8. Load the file\n");
printf(" 9. exit\n");
printf(" ***********************************************\n");
do{
printf("\n Enter you choice(0~9):"); /*提示输入选项*/
scanf("%s",s); /*输入选择项*/
c=atoi(s); /*将输入的字符串转化为整型数*/
}while(c<0||c>9); /*选择项不在0~9之间重输*/
return c; /*返回选择项,主程序根据该数调用相应的函数*/
}
/*输入函数*/
int enter(FLY t[])
{
int i,k,n,m,w,j;
char *s;
clrscr(); /*清屏*/
printf("input the flight's count(n<=40):");/*输入航线总数*/
scanf("%d",&n);
while(n>40||n<0)
{
clrscr();
printf("input error!!!input again(0<n<=40):");/*输入航线总数*/
scanf("%d",&n);
}
printf(" input the flight's information\n\n");/*提示信息*/
printf("flightname start-city end-city start-time end-time room price discount\n");
printf("------------------------------------------------------------------------------\n");
for(i=0;i<n;i++)
{
scanf("%s",t[i].planenumber);/*输入姓名*/
gotoxy(13,6+i);/*光标跳到地址栏*/
scanf("%s",t[i].city1);/*输入起飞城市*/
gotoxy(25,6+i);
scanf("%s",t[i].city2);/*输入降落城市*/
gotoxy(36,6+i);
scanf("%s",t[i].time1);/*输入起飞时间*/
gotoxy(47,6+i);
scanf("%s",t[i].time2);/*输入降落时间*/
gotoxy(57,6+i);
scanf("%d",&t[i].room);/*输入舱位数*/
gotoxy(64,6+i);
scanf("%s",t[i].price);/*输入票价*/
gotoxy(73,6+i);
scanf("%s",t[i].discount);/*输入折扣*/
}
printf("-----------------------------------------------------------------------------\n");
for(i=0;i<n;i++)t[i].sit=0;
return n; /*返回记录条数*/
}
/*显示记录,参数为记录数组和记录条数*/
void list(FLY t[],int n)
{
int i;
clrscr();
printf("flightname start-city end-city start-time end-time room price discount\n");
printf("------------------------------------------------------------------------------\n");
for(i=0;i<n;i++)
printf("%-12s%-12s%-10s%-12s%-10s%-7d%-7s%-7s\n",t[i].planenumber,t[i].city1,t[i].city2,t[i].time1,t[i].time2,t[i].room,t[i].price,t[i].discount);
printf(" ************************end*******************\n");
}
/*按航班号查找记录*/
void search1(FLY t[],int n)
{
char s[20]; /*保存待查找航班名字符串*/
int i;
clrscr(); /*清屏*/
printf("please input the flightname that you want to search:");
scanf("%s",s); /*输入待查找航班名*/
for(i=0;i<n;i++)/*从第一条记录开始,直到最后一条*/
{
if(strcmp(s,t[i].planenumber)==0) /*记录中的航班名和待比较的是否相等*/
break; /*相等,则返回该记录的下标号,程序提前结结束*/
}
if(i>n-1) /*如果整数i值大于n-1,说明没找到*/
printf("not found\n");
else
{
printf("flightname start-city end-city start-time end-time room price discount\n"); /*显示记录*/
printf("------------------------------------------------------------------------------\n");
printf("%-12s%-12s%-10s%-12s%-10s%-7d%-7s%-7s\n",t[i].planenumber,t[i].city1,t[i].city2,t[i].time1,t[i].time2,t[i].room,t[i].price,t[i].discount);
}
}
/*按起降城市查找记录*/
void search2(FLY t[],int n)
{
char s1[20];
char s2[20];
int i;
clrscr(); /*清屏*/
printf("please input the start-city:");
scanf("%s",s1); /*输入起飞城市名*/
printf("please input the end-city:");
scanf("%s",s2); /*输入降落城市名*/
for(i=0;i<n;i++)/*从第一条记录开始,直到最后一条*/
{
if((strcmp(s1,t[i].city1)==0)&&(strcmp(s2,t[i].city2)==0)) /*记录中的城市和待比较的是否相等*/
break; /*相等,则返回该记录的下标号,程序提前结结束*/
}
if(i>n-1) /*如果整数i值大于n-1,说明没找到*/
printf("not found\n");
else
{
printf("flightname start-city end-city start-time end-time room price discount\n"); /*找到,显示记录*/
printf("------------------------------------------------------------------------------\n");
printf("%-12s%-12s%-10s%-12s%-10s%-7d%-7s%-7s\n",t[i].planenumber,t[i].city1,t[i].city2,t[i].time1,t[i].time2,t[i].room,t[i].price,t[i].discount);
}
}
/*订票*/
void book(FLY t[],int n)
{
char s[20],number1[10],name1[10],id1[20],flightname1[10];
int i,j=0,m,k,count1;
clrscr(); /*清屏*/
printf("How many tickets do you want to book:");
scanf("%d",&m);
printf("number name ID book-count flightname\n"); /*提示信息*/
printf("------------------------------------------------------------\n");
for(k=0;k<m;k++)
{
scanf("%s",number1);
gotoxy(13,4+k);/*光标跳到地址栏*/
scanf("%s",name1);/*输入订票客户姓名*/
gotoxy(25,4+k);
scanf("%s",id1);/*输入证件号*/
gotoxy(43,4+k);
scanf("%d",&count1);/*输入订票票数*/
gotoxy(53,4+k);
scanf("%s",flightname1);/*输入航班号*/
for(i=0;i<n;i++)/*从第一条记录开始,直到最后一条*/
{
if(strcmp(flightname1,t[i].planenumber)==0) /*记录中的航班名和待比较的是否相等*/
{
j=t[i].sit;
strcpy(t[i].guest[j].number,number1);
strcpy(t[i].guest[j].name,name1);
strcpy(t[i].guest[j].id,id1);
t[i].guest[j].count=count1;
strcpy(t[i].guest[j].flightname,flightname1);
t[i].room=t[i].room-count1;
t[i].sit++;
break; /*相等,则返回该记录的下标号,程序提前结结束*/
}
}
if(i>n-1) /*如果整数i值大于n-1,说明没找到*/
{
printf("Sorry!No this flight\n");
m=m+2;
k++;
}
}
}
/*退票*/
void quit(FLY t[],int n)
{
char s1[20],s2[20]; /*保存待查找航班名和证件号字符串*/
int i,k,j,h,l,ch;
clrscr(); /*清屏*/
printf("please input the flightname that you want to quit:");
scanf("%s",s1); /*输入待查找航标名*/
printf("please input the your id:");
scanf("%s",s2); /*输入待查找证件号*/
printf("number name ID book-count flightname\n"); /*显示提示*/
printf("------------------------------------------------------------\n");
for(i=0;i<n;i++)/*从第一条记录开始,直到最后一条*/
{
for(j=0;j<t[i].sit;j++)
if((strcmp(s1,t[i].guest[j].flightname)==0)&&(strcmp(s2,t[i].guest[j].id)==0))
{
printf("%-11s%-16s%-16s%-14d%-10s\n",t[i].guest[j].number,t[i].guest[j].name,t[i].guest[j].id,t[i].guest[j].count,t[i].guest[j].flightname);
t[i].room=t[i].room+t[i].guest[j].count;
l=j;
h=i;
break;
}
}
i=h;
if(i>n-1) /*如果整数i值大于n-1,说明没找到*/
printf("not found\n");
else
{
printf("Are you sure delete it(1/0)\n"); /*确认是否要删除*/
scanf("%d",&ch); /*输入一个整数0或1*/
if(ch==1) /*如果确认删除整数为1*/
{
for(k=l+1;k<t[i].sit;k++)
{
strcpy(t[i].guest[k-1].number,t[i].guest[k].number); /*将后一条记录的姓名拷贝到前一条*/
strcpy(t[i].guest[k-1].name,t[i].guest[k].name);
strcpy(t[i].guest[k-1].id,t[i].guest[k].id);
t[i].guest[k-1].count=t[i].guest[k].count;
strcpy(t[i].guest[k-1].flightname,t[i].guest[k].flightname);
}
t[i].sit--;
}
printf("quit success!!\n");/*提示退票成功*/
}
}
/*修改航班信息*/
void channge(FLY t[],int n)
{
char s[20]; /*要删除记录的姓名*/
int i,j;
clrscr(); /*清屏*/
printf("please input the flightname that you want to channge:"); /*提示信息*/
scanf("%s",s);/*输入航班名*/
for(i=0;i<n;i++)/*从第一条记录开始,直到最后一条*/
{
if(strcmp(s,t[i].planenumber)==0) /*记录中的航班名和待比较的是否相等*/
break; /*相等,则返回该记录的下标号,程序提前结结束*/
}
if(i>n-1) /*如果整数i值大于n-1,说明没找到*/
printf("not found\n");
else
{
printf("flightname start-city end-city start-time end-time room price discount\n"); /*找到,显示原先记录*/
printf("------------------------------------------------------------------------------\n");
printf("%-12s%-12s%-10s%-12s%-10s%-7d%-7s%-7s\n",t[i].planenumber,t[i].city1,t[i].city2,t[i].time1,t[i].time2,t[i].room,t[i].price,t[i].discount);
printf("please input the new information:\n");
scanf("%s",t[i].planenumber);/*输入航班名*/
gotoxy(13,6+i);/*光标跳到地址栏*/
scanf("%s",t[i].city1);/*输入起始城市*/
gotoxy(25,6+i);
scanf("%s",t[i].city2);/*输入终点城市*/
gotoxy(35,6+i);
scanf("%s",t[i].time1);/*输入起飞时间*/
gotoxy(47,6+i);
scanf("%s",t[i].time2);/*输入降落时间*/
gotoxy(57,6+i);
scanf("%d",t[i].room);/*输入座位号*/
gotoxy(64,6+i);
scanf("%s",t[i].price);/*输入票价*/
gotoxy(71,6+i);
scanf("%s",t[i].discount);/*输入折扣*/
}
}
/*保存资料*/
void save(FLY t[],int n)
{
int i,j;
FILE *fp; /*指向文件的指针*/
if((fp=fopen("record1.txt","wb"))==NULL) /*打开文件,并判断打开是否正常*/
{
printf("can not open file\n");/*没打开*/
exit(1); /*退出*/
}
printf("\nSaving file\n"); /*输出提示信息*/
fprintf(fp,"%d",n); /*将记录数写入文件*/
fprintf(fp,"\r\n"); /*将换行符号写入文件*/
for(i=0;i<n;i++)
{
fprintf(fp,"%s %s %s %s %s %d %s %s",t[i].planenumber,t[i].city1,t[i].city2,t[i].time1,t[i].time2,t[i].room,t[i].price,t[i].discount);
fprintf(fp,"\r\n"); /*将换行符号写入文件*/
fprintf(fp,"%d",t[i].sit); /*将记录数写入文件*/
fprintf(fp,"\r\n"); /*将换行符号写入文件*/
for(j=0;j<t[i].sit;j++)
{fprintf(fp,"%s %s %s %d %s",t[i].guest[j].number,t[i].guest[j].name,t[i].guest[j].id,t[i].guest[j].count,t[i].guest[j].flightname);/*格式写入记录*/
fprintf(fp,"\r\n"); /*将换行符号写入文件*/
}
}
fclose(fp);/*关闭文件*/
printf("****save success***\n"); /*显示保存成功*/
}
/*读入函数,参数为结构体数组*/
int load(FLY t[])
{
int i,n,j;
FILE *fp; /*指向文件的指针*/
if((fp=fopen("record1.txt","rb"))==NULL)/*打开文件*/
{
printf("can not open file\n"); /*不能打开*/
exit(1); /*退出*/
}
fscanf(fp,"%d",&n); /*读入记录数*/
for(i=0;i<n;i++)
{fscanf(fp,"%s %s %s %s %s %d %s %s",t[i].planenumber,t[i].city1,t[i].city2,t[i].time1,t[i].time2,&t[i].room,t[i].price,t[i].discount);
fscanf(fp,"%d",&t[i].sit); /*读入记录数*/
for(j=0;j<t[i].sit;j++)
fscanf(fp,"%s %s %s %d %s",t[i].guest[j].number,t[i].guest[j].name,t[i].guest[j].id,&t[i].guest[j].count,t[i].guest[j].flightname); /*按格式读入记录*/
}
fclose(fp); /*关闭文件*/
printf("You have success read data from file!!!\n\n\n\n"); /*显示保存成功*/
return n; /*返回记录数*/
}
/*主函数*/
main()
{ int i;
FLY flight[Q];
int length; /*保存记录长度*/
clrscr(); /*清屏*/
textcolor(YELLOW); /*字体颜色*/
textbackground(BLUE);/*背景颜色*/
for(;;)/*无限循环*/
{
switch(menu_select()) /*调用主菜单函数,返回值整数作开关语句的条件*/
{
case 0:length=enter(flight);break;/*输入记录*/
case 1:list(flight,length);break; /*显示全部记录*/
case 2:search1(flight,length);break; /*查找记录*/
case 3:search2(flight,length);break; /*查找记录*/
case 4:book(flight,length);break; /*订票*/
case 5:quit(flight,length);break; /*退票*/
case 6:channge(flight,length);break; /*修改航班信息*/
case 7:save(flight,length);break; /*保存文件*/
case 8:length=load(flight); break; /*读文件*/
case 9:exit(0); /*如返回值为9则程序结束*/
}
}
}
F:\数据结构\FJ2.CPP(40) : error C2065: 'gotoxy' : undeclared identifier
F:\数据结构\FJ2.CPP(43) : error C2065: 'clrscr' : undeclared identifier
F:\数据结构\FJ2.CPP(357) : error C2065: 'textcolor' : undeclared identifier
F:\数据结构\FJ2.CPP(357) : error C2065: 'YELLOW' : undeclared identifier
F:\数据结构\FJ2.CPP(358) : error C2065: 'textbackground' : undeclared identifier
F:\数据结构\FJ2.CPP(358) : error C2065: 'BLUE' : undeclared identifier
F:\数据结构\FJ2.CPP(375) : warning C4508: 'main' : function should return a value; 'void' return type assumed
Error executing cl.exe.
求大神帮忙看看,这个要怎么改,拜托了!!!!