课程首页地址:http://blog.csdn.net/sxhelijian/article/details/7910565
【补充:趣味题——构造“菜单”】编写程序,显示“菜单”,由用户输入代号后,输出对所选项目的简短评论。运行结果参考下图:
#include <iostream> #include<Cmath> using namespace std; int main() { int c; cout<<"====今天晚饭吃什么?===="<<endl; cout<<"1. 山西刀削面"<<endl; cout<<"2. 兰州拉面"<<endl; cout<<"3. 西安羊肉泡馍"<<endl; cout<<"4. 烟台焖子"<<endl; cout<<"5. 西北风"<<endl; cout<<"请输入你选择的代号:"; cin>>c; switch(c) { case 1: cout<<"山西刀削面!西红柿肉汁两样调和都加上!"<<endl; break; case 2: cout<<"兰州拉面,多加点牛肉啥!拉成韭叶子的!"<<endl; break; case 3: cout<<"西安羊肉泡馍,吃老孙家的!"<<endl; break; case 4: cout<<"烟台焖子,好七!"<<endl; break; case 5: cout<<"喝西北风的娃伤不起……"<<endl; break; default: cout<<"你选错了!"<<endl; } return 0; }