package Comparetor;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInput;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
public class CoMpare {
// 输入N个正整数 然后从大到小排序 然后求出最小和最大的整数的阶乘
public static void main(String[] args) {
BufferedReader br = null;
BufferedWriter bw = null;
/*
* ObjectInput ois = null;//用来socket ObjectOutputStream oos =
* null;/用来socket
*/
br = new BufferedReader(new InputStreamReader(System.in));// 在Reader的构造的参数赢要reader这个类型的
// 那么inputStreamReader就是BufferedReader里面的
System.out.println("input some char");
String[] str = null;
try {
str = (br.readLine()).split(" ");
} catch (IOException e) {
e.printStackTrace();
}
List lists = new ArrayList();
for (String s : str) {
lists.add(new Integer(Integer.parseInt(s)));
}
System.out.println(lists.toString());
// 排序
Integer temp = null;
int maxsize = 1;
for (int i = 1; i < lists.size(); i++) {
temp = (Integer) lists.remove(i);
if (temp.intValue() >= ((Integer) lists.get(maxsize - 1))
.intValue()) {
lists.add(maxsize, temp);
maxsize++;
} else {
for (int j = 0; j < maxsize; j++) {
if (temp.intValue() <= ((Integer) lists.get(j)).intValue()) {
lists.add(j, temp);
maxsize++;
break;
}
}
}
}
System.out.println("after");
System.out.println(lists.toString());
System.out.println("min="+lists.get(0));
System.out.println("max="+lists.get(lists.size()-1));
//min的阶乘 //max的阶乘
int min = ((Integer)lists.get(0)).intValue();
int max = ((Integer)lists.get(lists.size()-1)).intValue();
int sum = 1 ;
if(min == 1 || min==0){
System.out.println("最小阶乘为1");
}else{
for(int i = 1 ; i<=min ; i++){
sum*=i;
}
System.out.println("最小数的阶乘为"+sum);
}
if(max== 1 || max==0){
System.out.println("最大阶乘为1");
}else{
for(int i = 1 ; i<max ; i++){
sum*=i;
}
System.out.println("最da数的阶乘为"+sum);
}
}
}