| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 511 人关注过本帖
标题:c语言随机类型问题
取消只看楼主 加入收藏
我是含羞草
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2015-5-18
结帖率:60%
收藏
已结贴  问题点数:15 回复次数:2 
c语言随机类型问题
想要制作一个和电脑玩石头剪刀布的随机游戏。运行后:

Let’s play geme!

石头剪刀布…石头(0) 剪刀(1) 布(2)
The number is:4
Please select a number between 0 and 2
The number is:2

You : 布
I: 剪刀
You lose!

You wanna play one more time? Yes(1) or No(0)
The number is:1

石头剪刀布…石头(0) 剪刀(1) 布(2)
The number is:0

You :石头
I:剪刀
You win!

You wanna play one more time? Yes(1) or No(0)
The number is:1

石头剪刀布…石头(0) 剪刀(1) 布(2)
The number is:2

You:布
I:布
Even!

You wanna play one more time? Yes(1) or No(0)
The number is:3
Input 0 or 1.
The number is:0
Good bye



老师什么都没说就让我们做了,好像要用到下列代码,但我不知道放哪里和怎么用:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int main(void){
 int a;
 srand(time(NULL));
 a=rand()%5;
}

麻烦老手解答!谢谢!
搜索更多相关主题的帖子: 石头剪刀布 between number c语言 
2015-05-27 22:34
我是含羞草
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2015-5-18
收藏
得分:0 
有人知道怎么做的吗,我今天试了下,不会啊 。求教!
2015-05-28 11:29
我是含羞草
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2015-5-18
收藏
得分:0 
4楼的好象运行不了额= =
2015-05-28 18:00
快速回复:c语言随机类型问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011806 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved