Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Sortieren {
- public int[] sortit(int[] array){
- for (int j=1; j<array.length;j++){
- int temp=Integer.MAX_VALUE;
- int position=0;
- int sicherung;
- for (int i = j; i<array.length;i++){
- if (array[i]<temp){
- temp=array[i];
- position = i;
- }
- }
- sicherung=array[j];
- array[j] = temp;
- array[position]=sicherung;
- }
- return array;
- }
- public static void main(String[] args){
- int[] test = {1,65,77,32,98,3,4,90};
- Sortieren test2 = new Sortieren();
- test2.sortit(test);
- String ergebnis = "Das Ergebnis lautet: ";
- for (int i = 0; i < test.length; i++) {
- ergebnis = ergebnis + test[i] +", ";
- }
- System.out.println(ergebnis);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement