#include <iostream>
Go to the source code of this file.
◆ main()
Definition at line 4 of file mode.cpp.
4 {
5 int input;
6 cin >> input;
7 int * set = new int[input];
8 for (int i = 0; i < input; i++) {
9 cin >> set[i];
10 }
11
12 int num1 = set[0];
13 int count1 = 1;
14 for (int i = 0; i < input; i++) {
15 int num2 = set[i];
16 int count2 = 0;
17 for (int i = 0; i < input; i++) {
18 if (set[i] == num2) {
19 count2++;
20 }
21 }
22 if (count2 > count1) {
23 count1 = count2;
24 num1 = num2;
25 }
26 }
27 cout << "The mode of the set is " << num1;
28 delete[] set;
29
30}