JAVA小程序:和电脑猜拳
import java.util.Scanner;
import java.util.Random;
public class Hello {
public static int judge(int j, int k)
{
int m;
if(j==k) m=0;
else if(j==0&&k==2||j==1&&k==0||j==2&&k==1) m=1;
else m=2;
return m;
}
public static void main(String[] args) {
System.out.println("scissor(0),rock(1),paper(2)");
System.out.println("Please Input Your Choose:");
int a=0,b=0;
Scanner input = new Scanner(System.in);
while(a!=2&&b!=2)
{
int Choose = input.nextInt();
int number = new Random().nextInt(3);
if (judge(Choose,number)==0)
{System.out.println("平手,please continue competition");
continue;}
else if(judge(Choose,number)==1)
{ System.out.println("You win this time,please continue competition");
a++;}
else if(judge(Choose,number)==2)
{ System.out.println("You are defeabed this time,please continue competition");
b++;
}
}
if(a==2)
System.out.println("You Win Last");
else if(b==2)
System.out.println("Computer Win Last");
}
}
最新文章
- [Java] Maven 建立 Spring MVC 工程
- 移动端图片上传解决方案localResizeIMG先压缩后ajax无刷新上传
- mongodb版本特性
- 2016HUAS_ACM暑假集训2B - The Suspects(感染者)
- 06SpringMvc_适配器
- winston日志管理2
- 使用Yii框架自带的CActiveForm实现ajax提交表单
- 【PHP代码审计】 那些年我们一起挖掘SQL注入 - 3.全局防护Bypass之Base64Decode
- iOS开发:告诉git不要跟踪UserInterfaceState.xcuserstate
- ARM中的PC和AXD的PC
- js写的简单轮播图
- 获取客户端IPAsp.Net
- poj_3468: A Simple Problem with Integers (树状数组区间更新)
- mysql错误集锦
- Python 上下文管理协议中的__enter__和__exit__基本理解
- 前端(一)之 HTML
- Eclipse Java EE IDE for Web Developers集成的Maven 3 指向自己安装的 Maven
- IDEA从SVN中导入多模块项目
- GO-time.after 用法
- 【读书笔记】iOS-网络-使用Bonjour实现自组织网络
热门文章
- Pie(二分)
- xml转换成数组array
- 【DP】编辑距离
- 关于网站图片格式 png,jpg,
- php实时推送系统消息给客户端
- Windows phone开发之文件夹与文件操作系列(一)文件夹与文件操作
- JDBC的详细使用
- 【sqli-labs】 less10 GET - Blind - Time based. - Double quotes (基于时间的双引号盲注)
- Python标准模块--logging(转载)
- C#连接Oracle数据库的方法(System.Data.OracleClient、Oracle.DataAccess.Client也叫ODP.net、Oracle.ManagedDataAccess.dll)