/*
Enter the integer numbers: 3 5 2 5 5 5 0
The largest number is: 5
The occurence count of the largest number is:4
*/
import java.util.Scanner;
public class ShowMaxNumberAndCount {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int number = 1, max, count = 1;
System.out.print("Enter the integer numbers: ");
max = input.nextInt();
while (number != 0) {
number = input.nextInt();
if (max < number)
max = number;
else if(max == number)
count++;
}
System.out.println("The largest number is: " + max);
System.out.println("The occurence count of the largest number is:" + count);
}
}
打印一组数字中最大数及出现的次数
最新推荐文章于 2019-06-19 23:43:09 发布