36 lines
848 B
Java
36 lines
848 B
Java
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]);
|
|
|
|
}
|
|
} |