System.out.println("请输入3个整数:"); int x = sc.nextInt(); int y = sc.nextInt(); int z = sc.nextInt(); System.out.println("从小到大排序后的结果:"); if (x < y && x < z) { if (y < z) { System.out.println(x + "<" + y + "<" + z); } else { System.out...
public static voidmain(String[] args){ int num1=0,num2=0,num3=0; Scanner sc=newScanner(System.in); num1=sc.nextInt(); num2=sc.nextInt(); num3=sc.nextInt(); intj; if(num1>num2){ j=num2; num2=num1; num1=j; } if(num1>num3){ j=num3; num3=num1; num1=j; } i...
public void compare(int x, int y, int z){ if(x < y){ if(x < z){ System.out.println(x); if(y < z){ System.out.println(y); System.out.println(z); }else { System.out.println(z); System.out.println(y); } }else { ...
题目:输入三个整数x,y,z,请把这三个数由小到大输出。1.程序分析:我们想办法把最小的数放到x上,先将x与y进行比较,如果x>y则将x与y的值进行交换,然后再用x与z进行比较,如果x>z则将x与z的值进行交换,这样能使x最小。2.程序源代码:main(){ int x,y,z,t;scanf("%d%d%d",&x...
//首先找到最小数 int min=x; if(x>y){ int temp =x;x=y; y=temp; } //交换x和y if(x>z){ int temp=x; x=z; z=temp; } if(y>z){ System.out.println(x+"<"+z+"<"+y) ; }else{ System.out.println(x+"<"+y+"<"+z) ;...
int z = s.nextInt(); comp.compare(x,y,z); } } class CompareMax{ public void compare(int x, int y, int z) { if(x>y) { int max =x; x=y; y=max; }if(x>z) { int max =x; x=z; z=max; }if(y>z) { int max = y; y=z; z=max; } System.out.println("由小...
输入三个整数x,y,z,请把这三个数由小到大输出。 实现代码: 第1种方法: import java.util.Scanner; public class xyzMaxMin{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("请输入3个整数:"); ...
输入三个整数x,y,z,请把这三个数由小到大输出。 实现代码: 第1种方法: import java.util.Scanner;public class xyzMaxMin{public static void main(String[] args) {Scanner sc = new Scanner(System.in);System.out.println("请输入3个整数:");int x = sc.nextInt();int y = sc.nextInt();int...
public static void main(String[] args){ Scanner input = new Scanner(System.in);System.out.println("input three number you want sort:");int x = input.nextInt();int y = input.nextInt();int z = input.nextInt();if(compare(x, y)){ if(compare(y, z)){ System.out....
1 package FushiExam; 2 import java.util.*; 3 public class Text_15_1 { 4 5 public static void main(String[] args) { 6 // 输入三个整数x,y,z,请把这三个数由小到大输出 7 //S