- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
// -1 esli NotFound, snachala massiv potom element
static int najtiElementVMassive(Object massiv,Object element){
if(massiv instanceof int[]) {
for(int i=0; i<((int[])massiv).length; ++i)
if(((int[])massiv)[i]==(int)element)
return i;
} else if(massiv instanceof byte[]) {
for(int i=0; i<((byte[])massiv).length; ++i)
if(((byte[])massiv)[i]==(byte)element)
return i;
} else if(massiv instanceof boolean[]) {
for(int i=0; i<((boolean[])massiv).length; ++i)
if(((boolean[])massiv)[i]==(boolean)element)
return i;
} else if(massiv instanceof char[]) {
for(int i=0; i<((char[])massiv).length; ++i)
if(((char[])massiv)[i]==(char)element)
return i;
} else if(massiv instanceof float[]) {
for(int i=0; i<((float[])massiv).length; ++i)
if(((float[])massiv)[i]==(float)element)
return i;
} else if(massiv instanceof double[]) {
for(int i=0; i<((double[])massiv).length; ++i)
if(((double[])massiv)[i]==(double)element)
return i;
} else if(massiv instanceof short[]) {
for(int i=0; i<((short[])massiv).length; ++i)
if(((short[])massiv)[i]==(short)element)
return i;
} else if(massiv instanceof long[]) {
for(int i=0; i<((long[])massiv).length; ++i)
if(((long[])massiv)[i]==(long)element)
return i;
} else {
try {
for(int i=0; i<((Object[])massiv).length; ++i)
if(sravnitMassivi(((Object[])massiv)[i],element))
return i;
} catch (Exception e) {
for(int i=0; i<((Object[])massiv).length; ++i)
if((((Object[])massiv)[i]).equals(element))
return i;
}
}
return -1;
}
static boolean sravnitMassivi(Object massiv1,Object massiv2) {
try {
if((((Object[])massiv1)).length!=(((Object[])massiv2)).length) return false;
boolean ravni=true;
for(int i=0; i<(((Object[])massiv1)).length; ++i)
ravni=ravni&&sravnitMassivi((((Object[])massiv1))[i],(((Object[])massiv2))[i]);
return ravni;
} catch (Exception e) {
if(massiv1 instanceof int[]) {
return Arrays.equals((int[])massiv1,(int[])massiv2);
} else if(massiv1 instanceof byte[]) {
return Arrays.equals((byte[])massiv1,(byte[])massiv2);
} else if(massiv1 instanceof boolean[]) {
return Arrays.equals((boolean[])massiv1,(boolean[])massiv2);
} else if(massiv1 instanceof char[]) {
return Arrays.equals((char[])massiv1,(char[])massiv2);
} else if(massiv1 instanceof float[]) {
return Arrays.equals((float[])massiv1,(float[])massiv2);
} else if(massiv1 instanceof double[]) {
return Arrays.equals((double[])massiv1,(double[])massiv2);
} else if(massiv1 instanceof short[]) {
return Arrays.equals((short[])massiv1,(short[])massiv2);
} else if(massiv1 instanceof long[]) {
return Arrays.equals((long[])massiv1,(long[])massiv2);
} else {
return massiv1.equals(massiv2);
}
}
}