#include <iostream>
using namespace std;
void findFrequency( int arr[ ] , int size) {
bool counted[ 100 ] = { false } ;
for ( int i = 0 ; i < size; i++ ) {
if ( ! counted[ arr[ i] ] ) {
int count = 0 ;
for ( int j = 0 ; j < size; j++ ) {
if ( arr[ j] == arr[ i] ) {
count++ ;
}
}
counted[ arr[ i] ] = true ;
cout << "Element " << arr[ i] << " occurs " << count << " time(s)." << endl;
}
}
}
int main( ) {
int arr[ 100 ] , size;
cout << "Enter the number of elements in the array: " ;
cin >> size;
cout << "Enter the elements of the array: " ;
for ( int i = 0 ; i < size; i++ ) {
cin >> arr[ i] ;
}
findFrequency( arr, size) ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZvaWQgZmluZEZyZXF1ZW5jeShpbnQgYXJyW10sIGludCBzaXplKSB7CiAgICBib29sIGNvdW50ZWRbMTAwXSA9IHtmYWxzZX07CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBzaXplOyBpKyspIHsKICAgICAgICBpZiAoIWNvdW50ZWRbYXJyW2ldXSkgeyAKICAgICAgICAgICAgaW50IGNvdW50ID0gMDsKCiAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgc2l6ZTsgaisrKSB7CiAgICAgICAgICAgICAgICBpZiAoYXJyW2pdID09IGFycltpXSkgewogICAgICAgICAgICAgICAgICAgIGNvdW50Kys7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIGNvdW50ZWRbYXJyW2ldXSA9IHRydWU7CgogICAgICAgICAgICBjb3V0IDw8ICJFbGVtZW50ICIgPDwgYXJyW2ldIDw8ICIgb2NjdXJzICIgPDwgY291bnQgPDwgIiB0aW1lKHMpLiIgPDwgZW5kbDsKICAgICAgICB9CiAgICB9Cn0KCmludCBtYWluKCkgewogICAgaW50IGFyclsxMDBdLCBzaXplOwogICAgY291dCA8PCAiRW50ZXIgdGhlIG51bWJlciBvZiBlbGVtZW50cyBpbiB0aGUgYXJyYXk6ICI7CiAgICBjaW4gPj4gc2l6ZTsKCiAgICBjb3V0IDw8ICJFbnRlciB0aGUgZWxlbWVudHMgb2YgdGhlIGFycmF5OiAiOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBzaXplOyBpKyspIHsKICAgICAgICBjaW4gPj4gYXJyW2ldOwogICAgfQoKICAgIGZpbmRGcmVxdWVuY3koYXJyLCBzaXplKTsKCiAgICByZXR1cm4gMDsKfQo=