Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import AlgoTools.IO;
- /* Importiere die Funktion für die Ein - und Ausgabe */
- public class MaxDist {
- /* Das Hauptprogramm */
- public static void main(String[] args) {
- // Hier der Code
- int [] array;
- do {
- array = IO.readInts("Bitte ein Integer-Array: ");
- } while (array.length == 0);
- int max = array[0];
- int min = array[0];
- for (int i = 1; i < array.length; i++) {
- if (array[i] < min) {
- min = array[i];
- }
- else if (array[i] > max) {
- max = array[i];
- }
- }
- IO.print ("Elemente mit größtem Abstand " + max + " und " + min);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement