dimanche 3 décembre 2017

How to find vector of unique elements and vector of repeats using for loops and if conditions?

I want a program that takes a vector of integers and creates two new vectors, one which contains each unique element, and another which contains the number of times these unique elements were repeated in the original vector.

So,

[1, 2, 2, 3, 3, 3] has unique elements [1,2,3] with the following number of repeats [1, 2, 3]

I know this has been asked before, but I want to achieve this using purely for loops and if conditions if need be. For the same reason, the code can be given in pseudocode obviously.

Please be nice, I am literally a beginner who learned programming syntax a few days ago.

Aucun commentaire:

Enregistrer un commentaire