Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class program {
- public static void main(String [] args){
- int [] szamok = {45,65,65,2,354,5,4,2423,3,4,5,4,2,43,3,25,4,6,57,3};
- String [] nevek = {"András" ,"Emíl" ,"Béla" ,"Láma" ,"Ilona" ,"Béna" ,"Zsombor" ,"Anasztázia"};
- intRendezes(szamok);
- stringRendezes(nevek);
- for(int x:szamok)
- System.out.print(x + " ");
- System.out.println();
- for(String y:nevek)
- System.out.print(y + " ");
- System.out.println();
- }
- }
- static int[] intRendezes(int [] tomb){
- for(int i=0; i<tomb.length-1; i++){
- for(int j=0; j<tomb.length-1; j++){
- if(tomb[j] > tomb[j+1]){
- int tmp = tomb[j];
- tomb[j] = tomb[j+1];
- tomb[j+1] = tmp;
- }
- }
- }
- return tomb;
- }
- static String[] stringRendezes(String [] args){
- for(int i=0; i<args.length-1; i++){
- for(int j=0; j<args.length-1; j++){
- if(args[j].compareTo(args[j+1]) >= 0){
- String tmp = args[j];
- args[j] = args[j+1];
- args[j+1] = tmp;
- }
- }
- }
- return args;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement