for(int i = 0; i < 5; ++i)
{
std::cout << a[i] << "was repeated " << std::count(a, a + 5, a[i]) << " times. " << std::endl;
}
I'm not sure what your 2nd and 3rd for loops are doing. I would just start over and use std::count. The only thing left for you to figure out is to determine how to avoid repeating the same text over and over. I just posted that to show how std::count can help simplify your program.
Thanks for the help. I want to know if there's another way to count the elements without using a function.Another more simple way. I'm using the second loop for to sort the array. I'm a beginner.
"Thanks for the help. I want to know if there's another way to count the elements without using a function.Another more simple way. I'm using the second loop for to sort the array. I'm a beginner."
I don't know how to answer this. How is writing your own loop simpler than calling a function that does the work for you?