我的思路:三个字母可以组成6种不同的字母组合,我把这六种都写出来,让后对应六种次序数字(数字是有序的)就可以组合了
import java.util.Scanner;
/**
*@author 作者 Your-Name:
*@version 创建时间:
*类说明:三个整数分别为 A,B,CA,B,C . 这三个数字不会按照这样的顺序给你,
*但它们始终满足条件:
*A<B<CA<B<C . 为了看起来更加简洁明了,
*我们希望你可以按照给定的顺序重新排列它们。
*/
public class MainP4414 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a,b,c;
Scanner input = new Scanner(System.in);
a = input.nextInt();
b = input.nextInt();
c = input.nextInt();
int max,min;
if(a > b)
{
max = a;
min = b;
}
else
{
max = b;
min = a;
}
if(max < c)
{
max = c;
}
if(min > c)
{
min = c;
}
String A;
A = input.next();
//System.out.println("A = " + A);
if(A.equals("ABC"))
{
System.out.printf("%d %d %d",min,(a + b + c - max - min),max);
}
if(A.equals("ACB"))
{
System.out.printf("%d %d %d",min,max,(a + b + c - max - min));
}
if(A.equals("BAC"))
{
System.out.printf("%d %d %d",(a + b + c - max - min),min,max);
}
if(A.equals("BCA"))
{
System.out.printf("%d %d %d",(a + b + c - max - min),max,min);
}
if(A.equals("CAB"))
{
System.out.printf("%d %d %d",max,min,(a + b + c - max - min));
}
if(A.equals("CBA"))
{
System.out.printf("%d %d %d",max,(a + b + c - max - min),min);
}
}
}