本题要求将输入的任意3个整数从小到大输出。
输入格式:
输入在一行中给出3个整数,其间以空格分隔。
输出格式:
在一行中将3个整数从小到大输出,其间以“->”相连。
输入样例:
4 2 8
输出样例:
2->4->8
暂时没有!!
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] str = scanner.nextLine().split(" ");
int[] ints = new int[str.length];
for (int j = 0; j < str.length; j++) {
ints[j] = Integer.parseInt(str[j]);
}
Arrays.sort(ints);
for (int i = 0; i < ints.length-1; i++) {
System.out.print(ints[i]+"->");
}
System.out.print(ints[ints.length-1]);
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
if (a > b) {
int temp = a;
a = b;
b = temp;
}
if (a > c) {
int temp = a;
a = c;
c = temp;
}
if (b > c) {
int temp = b;
b = c;
c = temp;
}
System.out.println(a + "->" + b + "->" + c);
}
}