Store name + number and sort in size order based on the numbers

后端 未结 5 1660
梦如初夏
梦如初夏 2021-01-24 07:20

Doing a college project and I\'m a bit stuck..

Basically, I need to take the string input for an employee name and an integer input for the amount of properties they sol

5条回答
  •  死守一世寂寞
    2021-01-24 08:07

    Use structs or a dictionary. I won't give you a line by line answer because it's an assignment and you need the problem solving practice but here is the steps:

    Read in the name and number like you are already. Rather than storing them in separate lists, create a new struct for each person with their number of properties sold and their name (Or put them in a dictionary key-value pair).

    Then you can sort the list (or dictionary) and print it out. Each item in the list/dictionary is guaranteed to be associated with the right data if you put them in right in the first place.

提交回复
热议问题