| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 757 人关注过本帖
标题:石头剪子布 (双人)
只看楼主 加入收藏
随心
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:12
帖 子:2577
专家分:250
注 册:2007-8-12
结帖率:100%
收藏
 问题点数:0 回复次数:4 
石头剪子布 (双人)

/*
Name: 石头剪子布 (双人)
Copyright:
Author:
Date: 13-10-07 09:15
Description:
*/
#include <iostream>
#include <string>
using namespace std;
void insShow()
{
cout<<"1-石头 2-剪子 3-布"<<endl;
}
int player1()
{
int cho1=0;
cout<<"player1\nchoice:";
cout.flush();
while(1)
{
cin>>cho1;
if(cho1<0&&cho1>4)
{
cout<<"输入错误!"<<endl;
continue;
}
else
break;
}
return cho1;
}
int player2()
{
int cho2=0;
cout<<"player2\nchoice:";
cout.flush();
while(1)
{
cin>>cho2;
if(cho2<0&&cho2>4)
{
cout<<"输入错误!"<<endl;
continue;
}
else
break;
}
return cho2;
}

int reslut(int a,int b)
{
if(a==1&&b==2)
return 1;
else if(a==1&&b==3)
return 2;
else if(a==2&&b==1)
return 2;
else if(a==2&&b==3)
return 1;
else if(a==3&&b==1)
return 1;
else if(a==3&&b==2)
return 2;
}

int main()
{
int res=0;
int x=0,y=0;
insShow();
x=player1();
system("cls");
insShow();
y=player2();
res=reslut(x,y);
cout<<"winer:"<<res<<endl;
system("pause");
return 0;
}

搜索更多相关主题的帖子: 石头 双人 剪子 
2007-10-24 23:33
万兽无缰
Rank: 1
等 级:新手上路
威 望:1
帖 子:296
专家分:0
注 册:2007-8-27
收藏
得分:0 
LZ发错地方了
不过程序没有问题啊
运行也可以

女朋友问我想怎么死~~~
             我说我想"爽死"
2007-10-25 10:34
永夜的极光
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2721
专家分:1
注 册:2007-10-9
收藏
得分:0 
没有平局的判断?

从BFS(Breadth First Study)到DFS(Depth First Study)
2007-10-25 10:48
万兽无缰
Rank: 1
等 级:新手上路
威 望:1
帖 子:296
专家分:0
注 册:2007-8-27
收藏
得分:0 
以下是引用永夜的极光在2007-10-25 10:48:26的发言:
没有平局的判断?

平局显示WINNER0的


女朋友问我想怎么死~~~
             我说我想"爽死"
2007-10-25 10:50
随心
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:12
帖 子:2577
专家分:250
注 册:2007-8-12
收藏
得分:0 
哦,这个疏忽了,多谢提醒。

天之道,利而不害。圣人之道,为而不争。信言不美,美言不信。善者不辩,辩者不善。知者不博,博者不知。
2007-10-26 16:38
快速回复:石头剪子布 (双人)
数据加载中...
 
   



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

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