Logic please.. With just using for or while loop...
Example:
int a[ ] = {2,3,2,3,4,4,5,1,3};
Output :
2 occurred 2 time
3 occurred 3 time
4 occurred 2 time
5 occurred 1 time
1 occurred 1 time
Logic please.. With just using for or while loop...
Example:
int a[ ] = {2,3,2,3,4,4,5,1,3};
Output :
2 occurred 2 time
3 occurred 3 time
4 occurred 2 time
5 occurred 1 time
1 occurred 1 time
The logic for this task could be as follow:
For each element in array a
check if element was previously used (may create array b
to add unique element)
1.1 If it was used continue
, otherwise add to array b
initialize counter and currentIndex variables
Search and count number of occurrences from the currentIndex, while currentIndex value is not -1
Print the element and its counter