This commit is contained in:
Mykola Fesenko
2025-07-29 09:05:07 +02:00
parent ce8e5eb3fe
commit 721931ac60
68 changed files with 608 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import java.util.Arrays;
public class J05A2 {
public static void main(String args[]){
int zahlen[] = {13, 9, 67, 42, 101, 99, 97, 112, 83, 5, 78};
// a)
for (int i = 0; i < zahlen.length; i++) {
System.out.println("Zahl Nr. " + (i+1) + " lautet " + zahlen[i]);
}
for (int zahl: zahlen ) {
System.out.println(zahl);
}
// b)
for (int i = 0; i < zahlen.length; i++) {
if (i < zahlen.length - 1) {
System.out.print(zahlen[i] + " - ");
} else {
System.out.println(zahlen[i]);
}
}
// c)
Arrays.sort(zahlen);
for (int zahl: zahlen ) {
System.out.println(zahl);
}
System.out.println("Kleinstes Element: " + zahlen[0]);
System.out.println("Größtes Element: " + zahlen[zahlen.length - 1]);
}
}