JAVA,三个数字排序,import java.util.Scanner;public class Text{public static void main(String[] args){Scanner input = new Scanner(System.in) ;System.out.print("input number1:");int number1 = input.nextInt() ;System.out.print("input number2:");int
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/18 09:25:21
JAVA,三个数字排序,import java.util.Scanner;public class Text{public static void main(String[] args){Scanner input = new Scanner(System.in) ;System.out.print("input number1:");int number1 = input.nextInt() ;System.out.print("input number2:");int
JAVA,三个数字排序,
import java.util.Scanner;
public class Text
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in) ;
System.out.print("input number1:");
int number1 = input.nextInt() ;
System.out.print("input number2:");
int number2 = input.nextInt() ;
System.out.print("input number3:");
int number3 = input.nextInt() ;
if ( number1 > number2 )
int = number1;
number1 = number2;
number2 = x ;
if (number3 < number2 && number3 > number1)
int x1 = number2;
number2 = number3;
number3 = x1;
if (number3 < number2 && number3 < number1)
int x2 = number3 ;
number3 = number2 ;
number2 = number1 ;
number1 = x2;
System.out.println(number1 + " " + number2 + " " + number3 + " ") ;
}
}
JAVA,三个数字排序,import java.util.Scanner;public class Text{public static void main(String[] args){Scanner input = new Scanner(System.in) ;System.out.print("input number1:");int number1 = input.nextInt() ;System.out.print("input number2:");int
看你是if语句里面的出错了.
例如,
if ( number1 > number2 )
int = number1;
number1 = number2;
number2 = x ;
错误了
改为
if ( number1 > number2 ){
int x= number1;
number1 = number2;
number2 = x ;
}
编程的时候,if条件成立,然后条件成立要“做”的东西,需要用大括号括起来(如果只做一步,就没必要.但是像你这里,很明显你是要做多步操作,故而不能省去大括号).其它if语句同错同理