输入两个整数a和b,把这两个数由小到大输出。java编程
展开全部
给你一个模板,你自己看看就会了。
import java.util.Scanner;
public class $ {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int size = 3;
int[] arr = new int[size];
for (int i = 0; i < size; i++) {
System.out.print("输入第" + (i + 1) + "个数:");
arr[i] = in.nextInt();
}
import java.util.Scanner;
public class $ {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int size = 3;
int[] arr = new int[size];
for (int i = 0; i < size; i++) {
System.out.print("输入第" + (i + 1) + "个数:");
arr[i] = in.nextInt();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.util.Scanner;
public class Test_1 {
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
int a = reader.nextInt();
int b = reader.nextInt();
if(a>b)
{
System.out.println(a);
System.out.println(b);
}
else
{
System.out.println(b);
System.out.println(a);
}
}
}
或者
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
int a = reader.nextInt();
int b = reader.nextInt();
System.out.println(a>b?a:b);
System.out.println(a>b?b:a);
}
}
public class Test_1 {
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
int a = reader.nextInt();
int b = reader.nextInt();
if(a>b)
{
System.out.println(a);
System.out.println(b);
}
else
{
System.out.println(b);
System.out.println(a);
}
}
}
或者
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
int a = reader.nextInt();
int b = reader.nextInt();
System.out.println(a>b?a:b);
System.out.println(a>b?b:a);
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询