java中3个数怎样比较大小
7个回答
展开全部
public class Three {
public void bigger(int[] num){
List<Integer> list=new ArrayList<Integer>();
for(int i:num){
list.add(i);
}
Collections.sort(list);
System.out.println("从小到大是:"+list);
}
public static void main(String[] args){
Three three=new Three();
int[] num={55,66,58};
three.bigger(num);
}
}
public void bigger(int[] num){
List<Integer> list=new ArrayList<Integer>();
for(int i:num){
list.add(i);
}
Collections.sort(list);
System.out.println("从小到大是:"+list);
}
public static void main(String[] args){
Three three=new Three();
int[] num={55,66,58};
three.bigger(num);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
如果是确定的三个数:
int x=9,y=20,z=5;
int max=x>y?x:y;
max=max>z?max:z;
System.out.println("The max:"+max);
如果是输入
import java.util.Scanner;
public class p35_4 {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int x=reader.nextInt();
int y=reader.nextInt();
int z=reader.nextInt();
int max=x>y?x:y;
max=max>z?max:z;
System.out.println("The max:"+max);
}
}
int x=9,y=20,z=5;
int max=x>y?x:y;
max=max>z?max:z;
System.out.println("The max:"+max);
如果是输入
import java.util.Scanner;
public class p35_4 {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int x=reader.nextInt();
int y=reader.nextInt();
int z=reader.nextInt();
int max=x>y?x:y;
max=max>z?max:z;
System.out.println("The max:"+max);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询