Book List


Submit solution

Points: 45 (partial)
Time limit: 1.0s
Memory limit: 256M

Authors:
Problem types

題目說明

請設計一類似書籍借閱清單的程式,讓使用者可以輸入自己借過的書籍名稱,並統計每本書被借閱的次數。
資料需存到HashMap<String, Integer>中,最後輸出整個借閱清單(書籍名與借閱次數)。

輸入

輸入借閱的書籍(一行一本書籍),直到輸入end代表結束

輸出

直接印出借閱清單的HashMap

邊界條件提示

  • 輸入的書籍可能有重複
  • 輸入的書籍名稱中間會有空格,所以每輸入一本書要用Enter隔開,nextLine()讀取一行資料。next()只會讀取第一個單詞喔!

測試資料 輸入

Harry Potter
Data Structures
Harry Potter
Python Basics
end

測試資料 輸出

{Harry Potter=2, Data Structures=1, Python Basics=1}

// HashMap無序,無需考慮輸出的排序問題


Comments

There are no comments at the moment.