0
Write an algorithm that takes an integer value m. Soon after, your program will receive a sequence of integer values greater than or equal to 0 and smaller than m, separated by a comma. Your program should print on screen how many times each sequence number appeared, in order.
Use the example below to understand how the data will be received and how the output should be displayed.
Input example:
4 3,1,3,0,1,1,1,3,1,3
Output example:
0,1 1.5 3,4
In the example above, the entries m = 4 and 3,1,3,0,1,1,1,3,1,3 represent a sequence of integer numbers separated by comma. Already the output indicates that the number 0 appeared 1 time, the number 1 appeared 5 times and the number 3 appeared 4 times in the sequence.
Only the following functions are allowed in this exercise: input print int str split Len append
Basically, just adapt the solutions of the links indicated above in the blue box. The first says how to separate the numbers (just change the
split(" ")
forsplit(",")
) and the second explains how to use theCounter
, that makes the count you need– hkotsubo
You tried to at least read the links indicated and adapt the code you have there for your case? If you have tried, just [Dit] the question putting the code you did and what specific difficulty you found.
– hkotsubo