广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 6610 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
guaat2001
数位造型
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x0
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[C/C++][求助] 急~c++作业~掷骰子游戏
掷骰子游戏
1.请由键盘输入你要使用几颗骰子(必须大于0,输入非正整数离开)
2.电脑 ..

访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容



献花 x0 回到顶端 [楼 主] From:台湾教育部 | Posted:2006-10-22 23:02 |
guaat2001
数位造型
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x0
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

我最后写出来的结果,但是是黑箱作业~谁能帮我解决一下这问题
还有我是用unix写的
老师规定的
好像没办法跑randmize这个函数
谢谢大家哦~^^



#include <stdio.h>
#include <stdlib.h>

int main()
{
int a,player,computer,flag=0,winc=0,winp=0;

while(flag==0)
  {
printf("plz enter the 1 to 3 bones to play the game;otherwise:exit\n");
scanf("%d",&a);

if(a>3)
    {
    exit(0);
    }
if(a<1)
    {
    exit(0);
    }
player=a+rand()%(5*a+1);
computer=a+rand()%(5*a+1);

if(computer > player)
    {
    printf("computer is winer and win: %d point is %d\n",++winc,computer);
    }
if(player > computer)
    {
    printf("player is winer and win: %d   point is %d\n",++winp,player);
    }
if(player == computer)
    {
    printf("Draw\n");
    }
if(winp==2)
    {
    flag=1;
    }
if(winc==2)
    {
    flag=2;
    }
if(flag==1)
    {
    printf("the winer is player");
    }
if(flag==2)
    {
    printf("the winer is computer ");
    }
  }
return 0;



}


献花 x0 回到顶端 [1 楼] From:台湾教育部 | Posted:2006-10-23 16:39 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.015253 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言