你好,帮你写了一个例子:
import java.lang.Math;
import java.util.Scanner;
public class max {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Please input 3 integers: ");
int x = Integer.parseInt(keyboard.nextLine());
int y = Integer.parseInt(keyboard.nextLine());
int z = Integer.parseInt(keyboard.nextLine());
int max = Math.max(x,y);
if(max>y){ //suppose x is max then compare x with z to find max number
max = Math.max(x,z);
}
else{ //if y is max then compare y with z to find max number
max = Math.max(y,z);
}
System.out.println("The max of three is: " + max);
}
}
请记得采纳哦!
源代码如下:
public class Test
{
public static void main(String arg[])
{int
a; int b; int c; int temp;
if (a
{temp=b;
b=a;
a=temp;
}
if (b
{temp=b;
b=c;
c=temp;
}
if (a
{temp=b;
b=a;
a=temp;
}
System.out.println("最大的数是:"a"+=);
}
}
!!