码迷,mamicode.com
首页 > 其他好文 > 详细

HW6.3

时间:2016-08-23 20:26:52      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

 1 import java.util.Scanner;
 2 
 3 public class Solution
 4 {
 5     public static void main(String[] args)
 6     {
 7         Scanner input = new Scanner(System.in);
 8 
 9         System.out.print("Enter the integers between 1 and 100: ");
10 
11         int number;
12         int[] storage = new int[101];
13 
14         while(true)
15         {
16             number = input.nextInt();
17             if(number == 0)
18                 break;
19             storage[number]++;
20         }
21 
22         input.close();
23 
24         for(int i = 1; i < 101; i++)
25         {
26             if(storage[i] == 1)
27                 System.out.println(i + " occurs 1 time");
28             else if(storage[i] > 1)
29                 System.out.println(i + " occurs " + storage[i] + " times");
30         }
31     }
32 }

 

HW6.3

标签:

原文地址:http://www.cnblogs.com/wood-python/p/5800572.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!