赞
踩
- /*
- *Copyright (c) 2014,烟台大学计算机学院
- *All gight reserved.
- *文件名称:temp.cpp
- *作者:曾晓
- *完成时间:2014年12月11日
- *版本号:v1.0
- */
- #include <iostream>
- using namespace std;
- void eat();
- void sleep();
- void hitdoudou();
- void run(void (*f)());
- int main()
- {
- int iChoice;
- do
- {
- cout<<"请选择(1-吃;2-睡;3-打;其他-退)";
- cin>>iChoice;
- if(iChoice==1)
- run(eat);
- else if(iChoice==2)
- run(sleep);
- else if(iChoice==3)
- run(hitdoudou);
- else
- break;
- }
- while(true);
- return 0;
- }
- void run(void (*f)())
- {
- (*f)();
- }
- void eat()
- {
- cout<<"我吃吃吃..."<<endl;
- }
- void sleep()
- {
- cout<<"我睡睡睡..."<<endl;
- }
- void hitdoudou()
- {
- cout<<"我不打还能干什么..."<<endl;
- }

运行结果:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。