zoukankan      html  css  js  c++  java
  • 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");
       }
    }
  • 相关阅读:
    软件工程,实践作业1_团队博客
    软件工程,实践作业1
    c# excel 读写 64位操作系统 64位excel
    pyfits fits图像区域选择
    python numpy中sum()时出现负值
    python 中模块的版本号
    numpy rand函数的应用
    python 字符串是否包含某个子字符串
    python 字符串格式化
    python 让异常名称显示出来
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/5213240.html
Copyright © 2011-2022 走看看