array max und min

master
jessi 2023-10-23 16:23:26 +02:00
parent d028638080
commit c91fca8046
1 changed files with 16 additions and 25 deletions

View File

@ -18,37 +18,28 @@ public class Array
for (int i= 0; i<10;i++){
System.out.println(arr[i]);
}
double Summe = 0;
double Summe = 0; // alle Arrays zusammenrechnen
for (int i= 0; i<10;i++){
Summe= Summe + arr[i];
}
System.out.println("Summe = " + Summe);
double min = 1;
double max = 0;
for (int i = 0; i<10;i++){
double zahl1 = arr[i];
for (int a = 0; a<10;a++){
if (zahl1 > arr[i])
System.out.println("Summe = " + Summe);
double max = arr[0]; //Maximalwert berechnen
double min = arr[0]; //Minimalwert berechnen
for (int a = 0; a<10;a++){
if (arr[a] > max)
{
System.out.print(min = arr[i]);
max = arr[a];
}
else if(arr[a] < min) {
min = arr[a];
}
/**
max = items[0];
min = items[0];
for (int i = 1; i < items.length; i++) {
if (items[i] > max) {
max = items[i];
}
else if (items[i] < min) {
min = items[i];
}
}
System.out.println(max); //100
System.out.println(min); //0
**/
System.out.println("maximal: " + max);
System.out.println("minimal: " + min);
}
}
}
}