首页 试题广场 > 试题详情
单选题

在Java中,运行下面代码,输入5和22后,输出结果是( )。
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
System.out.println("请输入两个整数!");
int[] nums = new int[2];
for (int i = 0; i < 2; i++) {
Scanner input = new Scanner(System.in);
nums[i] = input.nextInt();
}
if (nums[0] < nums[1]) {
int temp = nums[0];
nums[0] = nums[1];
nums[1] = temp;
}
System.out.println("The one is " + nums[0]);
System.out.println("The other is " + nums[1]);
}
}

  • A.The one is 5
    The other is 22
  • B.The one is 22
    The other is 5

  • C.The one is 22
    The other is temp
  • D.编译错误
提交并查看答案
下一题 上一题
Ke星伙伴们的回答/ 170个回答
关闭
关闭
QQ
交流群
邀请
好友
App
下载
意见
反馈
返回
顶部