显示一串数字的最大数及最大数出现的次数


package lyt;
import java.util.*;

public class Lyt6 {

 
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Scanner input=new Scanner(System.in);
     int []arr=new int[100];
     int max=0,count=0,m=0;
     System.out.print("请输入一串字符串:");
     for(int i=0;i<100;i++)
     {
      arr[i]=input.nextInt();
      m=i;
      if(arr[i]==0)
       break;
     }
     for(int j=0;j
     {
      if(arr[j]>max)
       max=arr[j];
     }
     for(int n=0;n
     {
      if(arr[n]==max)
       count++;
     }
     System.out.println("The largest number is :" + max);
     System.out.println("The occurrence count of the largest number is:" + count);
     }
     }

 

 

posted on 2012-12-07 23:56  木本  阅读(174)  评论(0编辑  收藏  举报

导航