You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							34 lines
						
					
					
						
							1.2 KiB
						
					
					
				
			
		
		
	
	
							34 lines
						
					
					
						
							1.2 KiB
						
					
					
				<html><body><pre><script>
 | 
						|
    var tab = [32,12,234,98,6,8,29,15,1053,14,34];
 | 
						|
    document.write("\ntrier un tableau par bulle");
 | 
						|
    document.write("\n"+tab.toString());
 | 
						|
    /*  
 | 
						|
        // parcourir en partant de la fin
 | 
						|
        pour i=11; i > 0; i--
 | 
						|
            // pour ce dernier nombre parcourir le tableau et le faire "remonter si il est plus grand"
 | 
						|
            // à la de la première itération le plus grand nombre est à la fin et on peut ne s'occuper que du reste du tableau.
 | 
						|
            pour j=0; j < i; j++
 | 
						|
                pour j allant de 0 à i-1
 | 
						|
                // si le chiffre suivant est plus grang inverser les valeurs
 | 
						|
                si tab[j+1] < tab[j]
 | 
						|
                    tmp = tab[j+1];
 | 
						|
                    tab[j+1] = tab[j];
 | 
						|
                    tab[j] = tmp;
 | 
						|
                fin si
 | 
						|
            fin pour
 | 
						|
        fin pour
 | 
						|
    */
 | 
						|
    for( i = tab.length ; i>0 ; i-- ) {
 | 
						|
        for( j=0 ; j < i-1 ; j++ ) {
 | 
						|
            if( tab[j+1] < tab[j])  {
 | 
						|
                var tmp = tab[j+1];
 | 
						|
                tab[j+1] = tab[j];
 | 
						|
                tab[j] = tmp;
 | 
						|
                console.log("\n"+tab.toString());
 | 
						|
            }
 | 
						|
        }
 | 
						|
        console.log("\n"+tab.toString());
 | 
						|
    }
 | 
						|
    document.write("\n"+tab.toString());
 | 
						|
</script></pre><body></html>    
 |