日期:2014-05-20 浏览次数:21272 次
import java.io.*;
public class Abc {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a number: ");
int a = Integer.parseInt(in.readLine());
System.out.print("Enter a number: ");
int b = Integer.parseInt(in.readLine());
System.out.print("Enter a number: ");
int c = Integer.parseInt(in.readLine());
//你随便输入3个数 ,然后排好序 ,a最小 ,b中间 ,c最大
int tmp ;
if (a > b){
tmp = a ;
a = b ;
b = tmp ;
}
if (b > c) {
tmp = b ;
b = c;
c = tmp;
}
System.out.println(a + " " + b + " " + c) ;
tmp = a ;
a = c ;
c = tmp ;
String str = "" ;
for (int i = c ; i<= a ; i++){
if (i != b ){
str = str + "," + i ;
}
}
System.out.println(str.substring(1)) ;
System.out.println("-------") ;
//你的方法只能是输入3个数 ,一定要从大到小
if (a > b) {
if (b > c) {
for (int i = 0; i <= (b - c - 1); i++) {
System.out.print((i + c) + ",");
}
for (int j = 1; j <= (a - b); j++) {
if (j == a-b){
System.out.print((j + b));
}else{
System.out.print((j + b) + ",");
}
}
}
}
}
}