SHOW:
|
|
- or go back to the newest paste.
| 1 | public class program {
| |
| 2 | public static void main(String [] args){
| |
| 3 | ||
| 4 | int [] szamok = {45,65,65,2,354,5,4,2423,3,4,5,4,2,43,3,25,4,6,57,3};
| |
| 5 | String [] nevek = {"András" ,"Emíl" ,"Béla" ,"Láma" ,"Ilona" ,"Béna" ,"Zsombor" ,"Anasztázia"};
| |
| 6 | ||
| 7 | intRendezes(szamok); | |
| 8 | stringRendezes(nevek); | |
| 9 | ||
| 10 | for(int x:szamok) | |
| 11 | System.out.print(x + " "); | |
| 12 | System.out.println(); | |
| 13 | ||
| 14 | for(String y:nevek) | |
| 15 | System.out.print(y + " "); | |
| 16 | System.out.println(); | |
| 17 | } | |
| 18 | - | } |
| 18 | + | |
| 19 | static int[] intRendezes(int [] tomb){
| |
| 20 | for(int i=0; i<tomb.length-1; i++){
| |
| 21 | for(int j=0; j<tomb.length-1; j++){
| |
| 22 | if(tomb[j] > tomb[j+1]){
| |
| 23 | int tmp = tomb[j]; | |
| 24 | tomb[j] = tomb[j+1]; | |
| 25 | tomb[j+1] = tmp; | |
| 26 | } | |
| 27 | } | |
| 28 | } | |
| 29 | return tomb; | |
| 30 | } | |
| 31 | ||
| 32 | ||
| 33 | static String[] stringRendezes(String [] args){
| |
| 34 | for(int i=0; i<args.length-1; i++){
| |
| 35 | for(int j=0; j<args.length-1; j++){
| |
| 36 | if(args[j].compareTo(args[j+1]) >= 0){
| |
| 37 | String tmp = args[j]; | |
| 38 | args[j] = args[j+1]; | |
| 39 | args[j+1] = tmp; | |
| 40 | } | |
| 41 | } | |
| 42 | } | |
| 43 | return args; | |
| 44 | } | |
| 45 | - | } |
| 45 | + | } |