#include<stdio.h>
#include<string.h>
#include"tools.h" //written by my self
int global_client_number = 0; //global veriate, to record the global_client_number of client
void Menu(struct tourist t[]); //the menu of the user interface
int Add(struct tourist t[]); //add info
int Input(struct tourist t[]); //to scan the information(info) of tourist
int Output(struct tourist t[], int i); //print a tourist's info
int Print(struct tourist t[]); //print all tourist's info
int Edit(struct tourist t[]); //edit info
int Search(struct tourist t[]); //search info
int SearchByName(struct tourist t[]);
int SearchByTime(struct tourist t[]);
int SearchBySite(struct tourist t[]);
int Delete(struct tourist t[]); //delete info
int DeleteByName(struct tourist t[]);
int DeleteByTime(struct tourist t[]);
int DeleteBySite(struct tourist t[]);
int Order(struct tourist t[]); //order info
int OrderByName(struct tourist t[]); //order by name
int OrderByTime(struct tourist t[]); //order by time
int OrderBySite(struct tourist t[]); //order by site
int main() //the entrance of programe
{
struct tourist client[10]; //define tourist array
Menu(client);
return 0;
}
void Menu(struct tourist t[]) //the menu of the user interface
{
system("cls");
fflush(stdin); //clear cache
bar(); //print # * 40
printf("Tourist Information Management System\n");
printf("Input a number to execute command which be tabbed\n\n");
printf("1.Add the information of tourist\n");
printf("2.Delete the information of tourist\n");
printf("3.Edit the information of tourist\n");
printf("4.Search the information of tourist\n");
printf("5.Sort the information of tourist\n");
printf("6.Display the information of tourist\n");
printf("0.Exit!!!\n");
printf("What would you wanna do ?: ");
fflush(stdin);
switch(getchar()) //switch
{
case '1': Add(t); break;
case '2': Delete(t); break;
case '3': Edit(t); break;
case '4': Search(t); break;
case '5': Order(t); break;
case '6': Print(t); break;
case '0':system("cls"); printf("Thanks for your use !!!"); Sleep(1500); goto loop; //to break the loop of menu
default:printf("There is something wrong with your input, please try again\n"); Sleep(1500); break;
}
Menu(t);
loop:;
} //end of menu
int Add(struct tourist t[]) //add
{
while(1)
{
system("cls");
global_client_number++;
Input(t);
Upload(t, global_client_number);
printf("Continue[y/n] ? : ");
fflush(stdin);//clear buffer
char sign = getchar();
if(sign == 'N' || sign == 'n') //???
{
printf("Saving\n");
loading(25);
break;
}
// else
// global_client_number++; //the number of client plus one
}
return Ok;
} //end of add
int Input(struct tourist t[]) //input
{
printf("Please input %dth information of tourist\n", global_client_number); //I fucked it up
printf("Name : ");
scanf("%s",t[global_client_number].name);
getchar();
printf("Scenic : ");
scanf("%s",t[global_client_number].placename);
getchar();
printf("sex : ");
scanf("%c",&t[global_client_number].sex);
getchar();
printf("Identification :");
scanf("%I64d",&t[global_client_number].pernum);
getchar();
printf("Phone No. : ");
scanf("%s",t[global_client_number].phone);
getchar();
printf("Date : ");
scanf("%d%d%d",&t[global_client_number].time.year,&t[global_client_number].time.month,&t[global_client_number].time.day);
getchar();
printf("DoT : ");
scanf("%d",&t[global_client_number].dot);
return Ok;
}//end of input
int Output(struct tourist t[], int i)
{
printf("%6.6s",t[i].name);
printf("%10.10s ",t[i].placename);
printf("\t%c ",t[i].sex);
printf("%I64d ",t[i].pernum);
printf("%11.11s ",t[i].phone);
printf("%4d-%02d-%02d ",t[i].time.year,t[i].time.month,t[i].time.day);
printf("\t%d",t[i].dot);
return Ok;
} //end of output
int Print(struct tourist t[]) //print
{
printf("Name\tScenic\tSex\tIdentification\tPhone\t\tdate\tDoT\n\n");
for(int i = 1; i <= global_client_number; i++)
{
Output(t, i); //used function output
printf("\n");
}
printf("\n");
fflush(stdin);
system("pause");
return Ok;
} //end of print
int Edit(struct tourist t[]) //edit //???????????????? ???????
{
system("cls");
int m,i;
char sel='y';
i=SearchByName(t);
if(i<0)
printf("Not found it\n");
else
{
printf("The information of tourist is : \n");
Output(t,i);
while(sel=='y')
{
printf("\n\nWhich info do you wanna edit ? : \n");
printf("1.Name\n");
printf("2.Scenic\n");
printf("3.Sex\n");
printf("4.Identification\n");
printf("5.Phone No.\n");
printf("6.Date\n");
printf("7.DoT\n");
scanf("%d",&m);
getchar();
switch(m)
{
case 1:printf("Name : \n");
scanf("%s",t[i].name);
getchar();
break;
case 2:printf("Scenic : \n");
scanf("%s",t[i].placename);
getchar();
break;
case 3:printf("Sex : \n");
scanf("%c",&t[i].sex);
getchar();
break;
case 4:printf("Identificaion : \n");
scanf("%I64d",&t[i].pernum);
getchar();
break;
case 5:printf("Phone No. : \n");
scanf("%s",t[i].phone);
getchar();
break;
case 6:printf("Date : \n");
scanf("%d%d%d",&t[i].time.year,&t[i].time.month,&t[i].time.day);
getchar();
break;
case 7:printf("DoT : \n");
scanf("%d",&t[i].dot);
getchar();
break;
}
printf("Continue[y/n] ? : ");
scanf("%c",&sel);
getchar();
}
}
return Ok;
} //end of edit
int Search(struct tourist t[])
{
system("cls");
bar();
printf("0.Return\n1.Search by name\n2.Search by site\n3.Search by date\n");
printf("Seclect one ? : ");
fflush(stdin);
switch(getchar())
{
case '1': printf("Name : "); Output(t, SearchByName(t)); printf("\n"); system("pause"); break;
case '2': printf("Time : "); Output(t, SearchByTime(t)); printf("\n"); system("pause"); break;
case '3': printf("Scenic : "); Output(t, SearchBySite(t)); printf("\n"); system("pause"); break;
default: break;
}
return Ok;
} //end of search
int SearchByName(struct tourist t[]) //search by name
{
// system("cls");
fflush(stdin);
// int sign = 0; //a mark when name be matched, sign = 1
char name[20]; //temp virable
scanf("%s", name);
for(int i = 1; i <= global_client_number; i++)
{
if(strcmp(t[i].name, name) == 0)
// sign = 1; //found it
return i;
}
printf("Not found it...");
return Err;
}//end of SearchByName
int SearchByTime(struct tourist t[]) //Search By Time
{
// int sign = 0; //a mark when name be matched, sign = 1
int year, month, day; //temp virable
fflush(stdin);
scanf("%d%d%d", &year, &month, &day);
for(int i = 1; i <= global_client_number; i++)
{
if(year == t[i].time.year && month == t[i].time.month && day == t[i].time.day)
// sign = 1; //found it
return i;
}
printf("Not found it...");
return Err;
} //end of SearchByTime
int SearchBySite(struct tourist t[]) //search by site
{
// int sign = 0; //a mark when name be matched, sign = 1
char placename[40]; //temp virable
fflush(stdin);
scanf("%s", placename);
for(int i = 1; i <= global_clie
CC++语言课程设计,旅游信息管理系统.zip
版权申诉
179 浏览量
2024-03-11
00:10:56
上传
评论
收藏 4KB ZIP 举报
博士僧小星
- 粉丝: 1931
- 资源: 5897
最新资源
- 基于Java的网上订餐系统设计源码 - online ordering system
- 基于Javascript的超级美眉网络资源管理应用模块设计源码
- 基于Typescript和PHP的编程知识储备库设计源码 - study-php
- Screenshot_2024-05-28-11-40-58-177_com.tencent.mm.jpg
- 基于Dart的Flutter小提琴调音器APP设计源码 - violinhelper
- 基于JavaScript和CSS的随寻订购网页设计源码 - web-order
- 基于MATLAB的声纹识别系统设计源码 - VoiceprintRecognition
- 基于Java的微服务插件集合设计源码 - wsy-plugins
- 基于Vue和微信小程序的监理日志系统设计源码 - supervisionLog
- 基于Java和LCN分布式事务框架的设计源码 - tx-lcn
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈