#include <stdio.h>
#include <unistd.h>
#include<windows.h>
void stop(void)
{
system("pause");
}
int main()
{
int stops=0,money=0,symbol=0,ticket=0; //先定义变量
char chose,choose;
system("cls");
printf("\n\t\t||------------------------------||");
printf("\n\t\t||------------------------------||"); //第一界面
printf("\n\t\t||-------------Welcome----------||");
printf("\n\t\t||----------use bus traffic-----||");
printf("\n\t\t||--------------card------------||");
printf("\n\t\t||------------------------------||");
printf("\n\t\t||------------------------------||");
printf("\n\n\n\n"); ///查找一下怎么清屏再写
Sleep(4000);
system("cls");
printf("\n\t\t||------------------------------||");
printf("\n\t\t||------------------------------||");
printf("\n\t\t| 1.Add new card |");
printf("\n\t\t| 2.Logout card |");
printf("\n\t\t| 3.Modify card |"); //第二界面
printf("\n\t\t| 4.Read card |");
printf("\n\t\t| 5.Save money |");
printf("\n\t\t| 6.Stat.max money |");
printf("\n\t\t| 7.Display |");
printf("\n\t\t| 8.Delete |");
printf("\n\t\t| 0.Exit |");
printf("\n\t\t||------------------------------||");
printf("\n\t\t||------------------------------||");
printf("\n\n\n");
printf("please give your change:");
scanf("%c",&chose); //chose 是自定义的 scanf 函数获取输入字符 !!!注意是字符型不是数字
switch(chose)
{
case '1':printf("\n\t\t Your chose is 1"); break;
case '2':printf("\n\t\t Your chose is 2"); break;
case '3':printf("\n\t\t Your chose is 3"); break;
case '4':printf("\n\t\t Your chose is 4"); ///输入界面
printf("\n\t\t please input your stops:");
scanf ("%c\n",&stops);
if (stops<1||stops>30)
{
printf("\n\t\t input error please try again");
getchar(); //重新回到上一界面
}
if (symbol==0)
{
if(stops<=10)
{
ticket=1;
symbol=1;
}
else if (stops<=15)
{ //symbol 起防止非法字符的措施
ticket=2;
symbol=1;
} //判断
else if (stops<=20)
{
ticket=2;
symbol=1;
}
else if (stops<=25)
{
ticket=3;
symbol=1;
}
else if(stops<=30)
{
ticket=4;
symbol=1;
}
}
printf("\n\t\t your ticket is %d.",ticket);
getchar();
break; //不能跳到主界面
case '5' :printf("\n\t\t save money:"); //case 5 的反复进行
scanf("\n\t\t %d",&money);
if (money<=0)
{
do
{
printf("\n\t\t your message is wrong,please input again:");
getchar(); //起到防止死循环的作用
//printf("\n\t\t How much your save:");
//scanf("\n\t\t %d",&money);
}
while(money<=0); //还是有问题,咋返回,为什么直接跳到后面一句,case没起作用
printf("\n\t\t you save %d $.",money);
getchar();
break;
}
case '6':printf ("\n\t\t Your chose is 6");break;
case '7':printf ("\n\t\t Your chose is 7");break;
case '8':printf ("\n\t\t Your chose is 8");break;
case '0':printf ("\n\t\t Are you sure exit:(y/n)");
scanf("\n\t\t %c",&choose);
do
{
printf("\n\t\t not normal char.");
getchar(); //老是用do while 感觉效果一般 ?????
}
while(choose!='Y'&&choose!='y'&&choose!='n'&&choose!='N');
if (choose=='y'||choose=='Y')
exit(0);
break;
default:printf("\n\t\t system is worry.");break;
gerchar();
}
stop();
return(0);
}