a032: Counting Numbers 數字計數
標籤 : Array 陣列
通過比率 : 89% (33 人 / 37 人 ) (非即時)
評分方式 :
Tolerant

最近更新 : 2019-02-11 16:37

內容

Write a program that reads numbers from the keyboard into an integer array. You may assume that there will be 50 or fewer entries in the array. Your program allows any number of numbers to be entered, up to 50 numbers. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.

撰寫一個程式,讀取輸入的數字存到整數陣列中。假設陣列中最多只有50個元素。你的程式可輸入任意數量的數字,最多50個數字。輸出為一個兩欄的清單。第一欄是不重複的陣列元素清單;第二欄是該每個元素出現的次數。清單以第一欄的元素由大到小排序。

輸入說明

User can keyin n number (n<=50), and end input by keyin -999.

使用者可以輸入n個數字(n<=50),輸入-999表示結束輸入。

輸出說明

The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.

輸出為一個兩欄的清單。第一欄是不重複的陣列元素清單;第二欄是該每個元素出現的次數。清單以第一欄的元素由大到小排序。

範例輸入
-12 3 -12 4 1 1
-12 1 -1 1 2 3 4 2 
3 -12 -999
範例輸出
4 2 
3 3 
2 2
1 4
-1 1
-12 4
測資資訊 :
記憶體限制 : 64 MB
隱藏 測資點#0 (50%): 1.0s , <1K
隱藏 測資點#1 (50%): 1.0s , <1K
提示 :
標籤:
Array 陣列
出處:
線上協同學習平臺 - ITSA 教育部資通訊軟體創新人才推升計畫 [編輯 :
zero_jason (zero_jason(MANAGER))
]


編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」