标题: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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-445853-1-1.html




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

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