-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
#include
#include
#include
using namespace std;
int main()
{
vector ages = {23, 45, 23, 30, 30, 30, 40, 45, 50, 50, 23, 23};
map<int, int> freq;
for (int age : ages) {
freq[age]++;
}
cout << "Age Distribution Histogram:\n";
for (auto& entry : freq) {
cout << entry.first << " | ";
for (int i = 0; i < entry.second; ++i)
cout << "*";
cout << " (" << entry.second << ")\n";
}
return 0;
}
Output:-
Age Distribution Histogram:
23 | **** (4)
30 | *** (3)
40 | * (1)
45 | ** (2)
50 | ** (2)
Metadata
Metadata
Assignees
Labels
No labels