master
parent
25f48e7116
commit
d6c8b53ae7
|
@ -61,10 +61,17 @@ public class ArrayExperimente
|
||||||
*/
|
*/
|
||||||
public static int indexVon(int gesucht, int[] array)
|
public static int indexVon(int gesucht, int[] array)
|
||||||
{
|
{
|
||||||
// TODO...
|
for(int i=0; i<array.length; i++)
|
||||||
|
{
|
||||||
|
if(array[i] == gesucht)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
// das return steht hier nur, damit der Compiler nicht meckert:
|
|
||||||
return -3245646;
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,10 +84,18 @@ public class ArrayExperimente
|
||||||
*/
|
*/
|
||||||
public static int maxWert(int[] array)
|
public static int maxWert(int[] array)
|
||||||
{
|
{
|
||||||
// TODO...
|
int bisherigesmax = array[0];
|
||||||
|
for(int i=0;i<array.length ;i++)
|
||||||
|
{
|
||||||
|
if(array[i]> bisherigesmax)
|
||||||
|
{
|
||||||
|
bisherigesmax = array[i];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bisherigesmax;
|
||||||
|
|
||||||
|
|
||||||
// das return steht hier nur, damit der Compiler nicht meckert:
|
|
||||||
return -346;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,10 +105,16 @@ public class ArrayExperimente
|
||||||
*/
|
*/
|
||||||
public static int maxIndex(int[] array)
|
public static int maxIndex(int[] array)
|
||||||
{
|
{
|
||||||
// TODO...
|
int bisherigesMaxIndex = 0;
|
||||||
|
for(int i=0;i<array.length ;i++)
|
||||||
|
{
|
||||||
|
if(array[i]> bisherigesMaxIndex)
|
||||||
|
{
|
||||||
|
bisherigesMaxIndex = i;
|
||||||
|
|
||||||
// das return steht hier nur, damit der Compiler nicht meckert:
|
}
|
||||||
return -324688;
|
}
|
||||||
|
return bisherigesMaxIndex;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue