Versionsvergleich
Aus ProgrammingWiki
Vergleich: 2013-03-13T12:20:31+00:00 → 2013-03-13T12:49:25+00:00
| − | <language>Java</language> |
| + | <language>Pascal</language> |
Test.. | |
| − | // Anfang Methoden |
| − | int a,b,F,U; |
| − | double d; |
| − | public void Rechne_ActionPerformed(ActionEvent evt) { |
| − | a = Integer.parseInt(Seitea.getText()); |
| − | b = Integer.parseInt(Seiteb.getText()); |
| − | U = 2*(a+b); |
| − | F = a*b; |
| − | d = Math.sqrt(a*a+b*b); |
| − | Flaeche.setText(Integer.toString(F)); |
| − | Umfang.setText(Integer.toString(U)); |
| − | Diagonale.setText(Double.toString(d)); |
| − | } |
| − | |
| − | // Ende Methoden |
| + | == Bubblesort == |
| + | <code id="514075d544794"> |
| + | public int[] ZufallsZahlen(int min, int max, int n) { |
| + | int[] Zahlen = new int[n]; |
| + | for (int i = 0; i < n; i++) |
| + | Zahlen[i] = (int)Math.floor(Math.random()*(max-min+1)+min); |
| + | return Zahlen; |
| + | } |
| + | public void ZahlenAusgabe(int[] liste) { |
| + | for (int i = 0; i < liste.length; i++) |
| + | if (i < liste.length-1) |
| + | System.out.print(liste[i]+", "); |
| + | else |
| + | System.out.println(liste[i]); |
| + | } |
| + | public void BubbleSort(int[] liste) { |
| + | int h; |
| + | for (int j = 0; j < liste.length-1; j++) |
| + | for (int i = j; i < liste.length; i++) |
| + | if (liste[i] < liste[j]) { |
| + | h = liste[i]; liste[i] = liste[j]; liste[j] = h; |
| + | } |
| + | } |
| + | </code> |
| + | <run id="514075d54480c"> |
| + | int[] ZahlenListe = ZufallsZahlen(1, 1000, 10); |
| + | System.out.println("Unsortierte Zufallszahlen:"); |
| + | ZahlenAusgabe(ZahlenListe); |
| + | System.out.println("Sortierte Zufallszahlen:"); |
| + | BubbleSort(ZahlenListe); |
| + | ZahlenAusgabe(ZahlenListe); |
| + | </run> |