forked from ossamamehmood/Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMode using pointers.cpp
More file actions
59 lines (59 loc) · 931 Bytes
/
Mode using pointers.cpp
File metadata and controls
59 lines (59 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//#include <iostream>
//using namespace std;
//
//int findMode(int* arr, int size)
//{
// int number;
// int max = 0;
// int count = 0;
// int mode=0;
// for (int i = 0; i < size; i++)
// {
// number = arr[i];
// count = 0;
// for (int j = 0; j < size; j++)
// {
// if (number == arr[j])
// {
// count++;
// }
// }
// if (max < count)
// {
// max = count;
// mode = number;
// }
// }
// if (max == 1)
// {
// return -1;
// }
// else
// {
// return mode;
// }
//}
//int main()
//{
// int size;
// int* arr;
// cout << "Total Number of Elements : ";
// cin >> size;
// arr = new int[size];
// cout << "Enter elements of array\n";
// for (int i = 0; i < size; i++)
// {
// cin >> arr[i];
// }
//
// int res=findMode(arr, size);
// if (res == -1)
// {
// cout << "No Mode Exist!\n";
// }
// else
// {
// cout << "Mode : " << res;
// }
// return 0;
//}