package cn.dadongzicool.chooseNumber;
import java.util.Scanner;
import java.util.Stack;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner reader = new Scanner(System.in);
Stack<Integer> stack = new Stack<Integer>();
String num[];
int tempLen;
int tempEntry[][];
System.out.println("请输入整形数字,以任何非数字字符结束输入:");
while(reader.hasNextInt())
{
stack.push(reader.nextInt());
}
tempLen = stack.size();
num = new String[tempLen];
tempEntry = new int[tempLen][2];
for(int i = 0;i < tempLen;i++){
num[i] = stack.pop().toString();
}
for(int i = 0;i < num.length;i++){
if(!num[i].equals("")){
tempEntry[i][0] = Integer.parseInt(num[i]);
}
for(int j = i;j < num.length;j++){
if(!num[j].equals("") && tempEntry[i][0] == Integer.parseInt(num[j])){
tempEntry[i][1]++;
num[j] = "";
}
}
}
int temp = 0;
if(tempEntry.length > 0){
temp = tempEntry[0][1];
}
for(int i = 0;i < num.length;i++){
if(tempEntry[i][1] > temp){
temp = tempEntry[i][1];
}
}
String bigNum = "";
for(int i = 0;i < num.length;i++){
if(tempEntry[i][1] == temp ){
if(bigNum.equals("")){
bigNum = tempEntry[i][0] + "";
}
if(tempEntry[i][0] > Integer.parseInt(bigNum)){
bigNum = tempEntry[i][0] + "";
}
}
}
System.out.println("重复次数最多且最大的数字为"+bigNum);
}
}