All pastes #414969 Raw Edit

Untitled

public java v1 · immutable
#414969 ·published 2007-03-29 13:05 UTC
rendered paste body
public class Boblesortering {    public static void skrivTabell( int[] a, String tekst ) {   System.out.println(tekst);  for (int i = 0; i < a.length; i++) {    System.out.print(a[i] + "  ");   }   System.out.println();  }    public static void sorter( int[] a ) {		boolean gjortNoe = false;				for (int i = a.length-1; i > 0; --i) { 			for (int j = 0; j < i; j++) { 				if ( a[j] > a[j+1]) { 					int tmp = a[j]; 					a[j] = a[j+1]; 					a[j+1]= tmp;					gjortNoe = true;	  			} //end if			} //end inner for			if(!gjortNoe) {				System.out.println("Ingen sortering foretatt");				break;			}		}  //end outer for	} //end sorter()    public static void main(String[] args) { 	 //int[] tall = { 8, 4, 2, 6, 1 }; 	 int[] tall = { 1,2,3,4,5,6,7,8 }; 	    skrivTabell(tall, "Usortert tabell:");   sorter(tall);   skrivTabell(tall, "Sortert tabell:");  }  }