请问一下这个程序有什么问题???

public class caiziyouxi {
	public static void main(String[] args) throws InterruptedException {
		int n = 0;
	    int m = 0;
	    int c = 0;
		int x = (int)(Math.random()*25);
		int y = (int)(Math.random()*25); /*定义要猜的数字的范围*/
        if (x > y) {System.out.println("要猜的数字在   "+y+"~"+x+" 之间");
                     n = y+(int)(Math.random()*x);
                     m = y+(int)(Math.random()*x);
                     c = y+(int)(Math.random()*x);}
        else if (y > x) {System.out.println("要猜的数字在   "+x+"~"+y+" 之间");
                         n = x+(int)(Math.random()*y);
                         m = x+(int)(Math.random()*y);
                         c = x+(int)(Math.random()*y);}
        else {x = (int)(Math.random()*100);
        if (x > y) {System.out.println("要猜的数字在   "+y+"~"+x+" 之间");
                    n = y+(int)(Math.random()*x);
                    m = y+(int)(Math.random()*x);
                    c = y+(int)(Math.random()*x);}
        if (y > x) {System.out.println("要猜的数字在   "+x+"~"+y+" 之间");
                    n = x+(int)(Math.random()*y);
                    m = x+(int)(Math.random()*y);
                    c = x+(int)(Math.random()*y);}
        }             /*输出要猜的数字的范围及定义要猜的数字*/Thread.sleep(2000);
        System.out.println("现在开始选定玩家");   
        int z = (int)(Math.random()*4);/*确定玩家数量为5*/
        String A = new String();
        if (z == 0) {A = "Mary";}
        else if (z == 1) {A = "Tom";}
        else if (z == 2) {A = "Steve";}
        else if (z == 3) {A = "Barry";}
        else {A = "Tony";}
        Thread.sleep(5000);/*程序延迟5S*/
        System.out.println("第一位玩家是:"+A);/*创建玩家A*/
        if (z < 4) {z = z + 1;}
        else {z = z - 1;}
        String B = new String();
        if (z == 0) {B = "Mary";}
        else if (z == 1) {B = "Tom";}
        else if (z == 2) {B = "Steve";}
        else if (z == 3) {B = "Barry";}
        else {B = "Tony";}
        Thread.sleep(3000);/*程序延迟3S*/
        System.out.println("第二位玩家是:"+B);/*创建玩家B*/Thread.sleep(1000);
        System.out.println("玩家开始猜数......");
        Thread.sleep(10000);/*程序延迟10S*/
        if (m == n) {System.out.println("恭喜选手"+A+"猜对了!!!");}
        else if (c == n) {System.out.println("恭喜选手"+B+"猜对了!!!");}
        else {System.out.println("很可惜两位玩家都猜错了,请重新开始猜数。");
              while (m > n|m < n|c > n|c < n){
            	  m++;c--;
            	  System.out.println("玩家开始猜数......");
                  Thread.sleep(5000);/*程序延迟5S*/
                  if (m == n) {System.out.println("恭喜选手"+A+"猜对了!!!");}
                  else if (c == n) {System.out.println("恭喜选手"+B+"猜对了!!!");}
                  else {System.out.println("很可惜两位玩家都猜错了,请重新开始猜数。");}
                  }
              }
        
        }
	}
	

为啥每次运行n和x、y的数都对不上???

MineDearm
浏览 1143回答 1
1回答

__innocence

没看你的逻辑,但是我觉得是这里错了:while (m > n|m < n|c > n|c < n)如果表示或,应该是while (m > n || m < n || c > n || c < n)一个竖线表示位运算,两个竖线表示或
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java