输入三个整数 x,y,z ,请把这三个数由小到大输出?

如题所述

import java.util.Scanner;
public class Prog15{
public static void main(String[] args){
Scanner scan = new Scanner(System.in).useDelimiter("\\D");
System.out.print(" 请输入三个数: ");
int x = scan.nextInt();
int y = scan.nextInt();
int z = scan.nextInt();
scan.close();
System.out.println(" 排序结果: "+sort(x,y,z));
}
// 比较两个数的大小
private static String sort(int x,int y,int z){
String s = null;
if(x>y){
int t = x;
x = y;
y = t;
}
if(x>z){
int t = x;
x = z;
z = t;
}
if(y>z){
int t = z;
z = y;
y = t;
}
s = x+" "+y+" "+z;
return s;
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2020-08-31
你第二个求累加和的意思不太明确~就只写了第一个~#include int factorial(int x)\x05\x05//求阶乘函数{\x05\x05int i;\x05if(x>1)\x0
第2个回答  2020-08-31
你只需要将三个整数,然后按大小的函数输入就可以了。
第3个回答  2020-08-31
输入三个字,儿子这具体你应该去找找专门的一些校医老的或者列个等式,看看有什么好的办法。
第4个回答  2020-08-31
输入三个整数差在这请把这三个数由
相似回答