2 ; Programme qui trie un tableau de 10 entiers
5 ; Attention, 2 octets par mot.
6 ; Étape 1 : lit 10 entier et les range dans vecteur
9 BRGE trier ; for(X=0;X<20;X+=2) {
10 DECI vecteur,x ; vecteur[X] = getInt();
12 BR in_loop ; } // fin for
13 ; Étape 2 : trie le vecteur (algo: tri par permutation)
16 loop_ix: BRLT afficher ; for(ix=18;ix>=0;ix-=2) {
18 STX jx,d ; for(jx=ix-2;jx>=0;jx-=2) {
23 BRLE next_jx ; if (vecteur[jx] > vecteur[ix]) {
24 STA tmp,d ; tmp = vecteur[jx];
28 STA vecteur,x ; vecteur[jx] = vecteur[ix];
31 STA vecteur,x ; vecteur[ix] = tmp;
35 BR loop_jx ; } // fin for jx
39 BR loop_ix ; } // fin for ix
40 ; Étape 3 : affiche le tableau trié
43 BRGE fin ; for(X=0;X<20;X++) {
45 CHARO '\n',i ; print(vecteur[X], "\n");
47 BR out_loop ; } // fin for
50 vecteur: .BLOCK 20 ; #2d10a vecteur de 10 entiers
51 ix: .BLOCK 2 ; #2d itérateur ix pour tri
52 jx: .BLOCK 2 ; #2d itérateur jx pour tri
53 tmp: .BLOCK 2 ; #2d variable temporaire pour échange