Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import AlgoTools.IO;
  2.  
  3. /* Importiere die Funktion für die Ein - und Ausgabe */
  4.  
  5. public class MaxDist {
  6.  
  7. /* Das Hauptprogramm */
  8. public static void main(String[] args) {
  9. // Hier der Code
  10.  
  11. int [] array;
  12. do {
  13. array = IO.readInts("Bitte ein Integer-Array: ");
  14. } while (array.length == 0);
  15.  
  16. int max = array[0];
  17. int min = array[0];
  18.  
  19. for (int i = 1; i < array.length; i++) {
  20. if (array[i] < min) {
  21.  
  22. min = array[i];
  23. }
  24. else if (array[i] > max) {
  25. max = array[i];
  26. }
  27. }
  28. IO.print ("Elemente mit größtem Abstand " + max + " und " + min);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement