永发信息网

在java中怎么比较三个整数大小例如(a ,b,c);并从小到大输出

答案:1  悬赏:30  手机版
解决时间 2021-06-09 07:31
  • 提问者网友:玫瑰园
  • 2021-06-08 06:47
在java中怎么比较三个整数大小例如(a ,b,c);并从小到大输出
最佳答案
  • 五星知识达人网友:三千妖杀
  • 2021-06-08 08:23

import java.util.*;
public class Exercise06
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in); //利用键盘输入功能
System.out.print(a=);
int a = input.nextInt() ; //输入数字a 只能为int类型
System.out.print(b=);
int b = input.nextInt() ;
System.out.print(c=);
int c = input.nextInt() ;
Exercise06 e = new Exercise06() ;
e.sort(a,b,c);
}
void sort(int a,int b,int c)
{
int temp = 0 ;
if(a>b){
temp = a;
a = b ;
b = temp ;
}
if(a>c){
temp = a;
a = c ;
c = temp ;
}
if(b>c){
temp = b;
b = c ;
c = temp ;
}
System.out.println(a+,+b+,+c);
}
}
不过我还是建议你多用一楼的方法


我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯