using System namespace lab2 class DifferentElements private int arr pr

 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
using System;
namespace lab2
{
class DifferentElements
{
private int[] arr;
private int countDiffVal;
public DifferentElements(int[] arr)
{
this.arr = arr;
}
public int GetCount()
{
int len = arr.Length;
int cnt = 0;
for(int i = 0; i < len; i++)
{
for (int j = 0; j < len; j++)
if (arr[i] == arr[j])
cnt++;
if (cnt < 2)
countDiffVal++;
cnt = 0;
}
return countDiffVal;
}
}
}