-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArraryTest.java
63 lines (61 loc) · 982 Bytes
/
ArraryTest.java
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
60
61
62
63
//maximum equal Array
package arraytest;
public class ArraryTest {
public static void main(String[] args) {
int a[]= {-2,-4,-6,-8,-11,13,16,16};
int len=a.length;
int min,max,i,countMin,countMax;
if(len==0)
{
System.out.println("Empty Array");
}
else if(len==1)
{
System.out.println("Array Must Have atleast 2 elements");
}
else
{
min=a[0];
max=a[0];
for(i=1;i<len;i++)
{
if(a[i]>max)
{
max=a[i];
}
if(a[i]<min)
{
min=a[i];
}
}
if(min==max)
{
System.out.println("Array Must Contain 2 different elements");
}
else
{
countMax=0;
countMin=0;
for(i=0;i<len;i++)
{
if(a[i]==max)
{
countMax++;
}
if(a[i]==min)
{
countMin++;
}
}
if(countMax==countMin)
{
System.out.println("This is a Maxim Equal Array");
}
else
{
System.out.println("This is not a Maxim Equal Array");
}
}
}
}
}