File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ #include <iostream>
2+ #include <string>
3+
4+ using namespace std ;
5+
6+ int main ()
7+ {
8+ cout << "Value of inputs in your array?" << endl ;
9+ int arraysize ;
10+ cin >> arraysize ;
11+
12+ cout << "Input array elements:" << endl ;
13+
14+ string array [arraysize ];
15+
16+ for (int i = 0 ; i < arraysize ; i ++ )
17+ {
18+ cin >> array [i ];
19+ }
20+
21+ int most_occur = 1 ;
22+
23+ for (int i = 0 ; i < arraysize - 1 ; i ++ )
24+ {
25+ int times_occur = 1 ;
26+
27+ for (int j = i + 1 ; j < arraysize ; j ++ )
28+ {
29+ if (array [i ]== array [j ])
30+ times_occur = times_occur + 1 ;
31+ }
32+
33+ if (times_occur > most_occur )
34+ {
35+ most_occur = times_occur ;
36+ }
37+
38+ }
39+
40+ if (most_occur > 1 )
41+ {
42+ cout << "Most occuring: " ;
43+ for (int i = 0 ; i < arraysize - 1 ; i ++ )
44+ {
45+ int times_occur = 1 ;
46+
47+ for (int j = i + 1 ; j < arraysize ; j ++ )
48+ {
49+ if (array [i ]== array [j ])
50+ times_occur = times_occur + 1 ;
51+ }
52+
53+ if (times_occur == most_occur )
54+ {
55+ cout << array [i ] << " " ;
56+ }
57+ }
58+ }
59+
60+ else
61+ {
62+ cout << "No specific array elements are repeating." ;
63+ }
64+
65+ return 0 ;
You can’t perform that action at this time.
0 commit comments