public class Four {
public static void main(String[] args) {
System.out.println("请输入a:");
Scanner sc1 = new Scanner(System.in);
int a = sc1.nextInt();
System.out.println("请输入b:");
Scanner sc2 = new Scanner(System.in);
int b = sc2.nextInt();
System.out.println("请输入c:");
Scanner sc3 = new Scanner(System.in);
int c = sc2.nextInt();
if (a>b&&a>c&&b>c)
{
System.out.println(a+" "+b+" "+c);
}else if (a>b&&a>c&&c>b)
{
System.out.println(a+" "+c+" "+b);
}
else if (b>a&&b>c&&a>c)
{
System.out.println(b+" "+a+" "+c);
}
else if(b>a&&b>c&&c>a)
{
System.out.println(b+" "+c+" "+a);
}
else if (c>a&&c>b&&a>b)
{
System.out.println(c+" "+a+" "+b);
}
else
{
System.out.println(c+" "+b+" "+a);
}
}
}
package cskaoyan;
public class cskaoyan34 {
@org.junit.Test
public void swap() {
java.util.Scanner in = new java.util.Scanner(System.in);
System.out.println("n1 = :");
int n1 = in.nextInt();
System.out.println("n2 = :");
int n2 = in.nextInt();
System.out.println("n3 = :");
int n3 = in.nextInt();
if (n1 > n2) {
n1 = n1 ^ n2;
n2 = n1 ^ n2;
n1 = n1 ^ n2;
}
if (n1 > n3) {
n1 = n1 ^ n3;
n3 = n1 ^ n3;
n1 = n1 ^ n3;
}
if (n2 > n3) {
n2 = n2 ^ n3;
n3 = n2 ^ n3;
n2 = n2 ^ n3;
}
System.out.println(n1 + " " + n2 + " " + n3);
in.close();
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。