函数的有关知识在后面章节会讲到,先提前了解下。在没有系统的学习完之前,咱们先来模仿着写一个例子,尝试这种有效的学习方法。
尝试下这样的学习方法。
显示功能选项
1.查询
2.取款
3.存款
4.转帐
0.退出
尝试下这样的学习方法。
显示功能选项
1.查询
2.取款
3.存款
4.转帐
0.退出
用户输入功能选择,根据给出的答复,用switch多分支完成对应的功能:
#include <iostream>
using namespace std;
int main()
{
char cChioce;
void cTaiYuan();
void cJinCheng();
void cDaTong();
do
{
cout<<""<<endl;
cout<<"五一到了,请选择一个地区做为作为旅游的地方!"<<endl<<endl;
cout<<"*1. 太原市"<<endl;
cout<<"*2. 晋城市"<<endl;
cout<<"*3. 大同市"<<endl;
cout<<"*0. 退出"<<endl;
cout<<"*请选择(0-3):";
cin>>cChioce;
if (cChioce=='1') // 我居然将==写成=
cTaiYuan();
else if (cChioce=='2')
cJinCheng();
else if (cChioce=='3')
cDaTong();
else if (cChioce=='0')
break;
else
{
cout<<"\007选择错误!"<<endl<<endl;
continue;
}
cout<<"恭喜你选择了一个地区做为你的五一旅游的地方!"<<endl<<endl<<endl;
}while(1);
return 0;
};
void cTaiYuan()
{
cout<<"你选择的地方是太原市!"<<endl;
}
void cJinCheng()
{
cout<<"你选择的地方是晋城市!"<<endl;
}
void cDaTong()
{
cout<<"你选择的地方是大同市!"<<endl;
}