第四周 摇骰子
来源:互联网 发布:大数据云计算研究方向 编辑:程序博客网 时间:2024/05/16 18:04
#include <iostream>#include <cstdlib>#include <ctime>using namespace std;class shaizi{public: int getdian();private: int dian;};int main(){ shaizi s1; cout << "摇出的点数" <<s1.getdian()<<endl; return 0;}int shaizi::getdian(){ srand(time(0)); dian=rand()%5+1; return dian;}运行结果
心得体会
与前面的知识相结合
****修改
将输出或者输入的工作放在main函数里面比较好
#include <iostream>#include <cstdlib>#include <ctime>
using namespace std;class shaizi{public: int getdian();private: int dian;};int main(){ shaizi s1; cout << "摇出的点数" <<s1.getdian()<<endl; return 0;}int shaizi::getdian(){ srand(time(0)); dian=rand()%5+1; return dian;}
0 0
- 第四周 摇骰子
- 摇骰子
- 摇骰子(娱乐)
- 随机数摇骰子
- 摇骰子的动画制作
- 【小程序】摇骰子游戏BETA版
- 摇骰子(随机数)2种方法
- wxpython编程示例:摇骰子程序,let's ROLL 6!!
- 第四周
- 第四周
- 第四周
- 第四周
- 第四周
- 第四周
- 第四周
- 第四周
- 第四周
- 第四周
- C#检查是否联网
- 央企总部离京争论:十八大后办事不再非到北京
- 电话面试技巧
- 函数指针和回调函数
- Android 模拟器和PC物理键盘映射
- 第四周 摇骰子
- 三角形类
- NYOJ 528 找球号(三)
- C语言中的排序、二分查找
- jq无序列表隐藏
- YouTube 的架构扩展
- log4j:WARN Please initialize the log4j system properly解决办法
- Js正则表达式大全
- 《暗黑破坏神3》游戏拍卖行今日关闭