//请输入星期几的第一个字母来判断一下是星期几,
//如果第一个字母一样,则继续判断第二个字母。
//Monday,Tuesday,Wensday,Thurseday,Friday,Saturday,Sunday
#include <iostream>
#include "stdio.h"
#include "conio.h"
using namespace std;
int main()
{
char letter;
cout<<"Please input the first letter of some day :"<<endl;
while((letter=getch())!='Y'){
switch(letter){
case 'M':cout<<"Monday"<<endl;
break;
case 'W':cout<<"Wensday"<<endl;break;
case 'F':cout<<"Friday"<<endl;break;
case 'T':cout<<"Please input the second letter : ";
if((letter=getch())=='u') cout<<"Tuesday"<<endl;
else if((letter=getch())=='h') cout<<"Thurseday"<<endl;
else cout<<"data error";
break;
case 'S':cout<<"Please input the second letter : ";
if((letter=getch())=='a') cout<<"Saturday"<<endl;
else if((letter=getch())=='u') cout<<"Sunday"<<endl;
else cout<<"data error";
break;
default:cout<<"Data Error";
}
}
cout << "Hello world!" << endl;
return 0;
}
运行结果为:
- class='magplus' title='点击查看原始大小图片' />
- 大小: 26.7 KB