首页 > 试题广场 >

假 设 x=3以及 y=2, 如果下面代码有输出的话,请给

[问答题]
 假 设 x=3以及 y=2, 如果下面代码有输出的话,请给出。如果 x=3并且 y=4,结果是什么呢?如 果 x=2 并且 y=2,结果是什么呢?绘制代码的流程图。 
     if (x > 2) {
         if (y > 2) { 
           z -=x + y;
            System.out.println(“z is ”+ z);
          }
      }
      else
      System.out.println(“x is ”+ x);
package ab;
import java.util.Scanner;
public class As {
    public static void main(String[] args) {
        int x,y;
        System.out.print("请输入x,y:");
        Scanner in=new Scanner(System.in);
        x=in.nextInt();
        y=in.nextInt();
            if (x > 2) {
                     if (y > 2) { 
                         int z;
                       z =x + y;
                        System.out.print("z is"+z);
                      }
                  }
                  else
                  System.out.print("x is"+x);
    }

}
好奇怪,代码哪错了?
发表于 2021-04-08 14:39:48 回复(4)