Sign in Join
Wiki copytemporary

Bubble sort/fr: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-Le tri à bulle est un algorithme de tri simple.
2-
3-## Contents
4-
5- * 1 Propriétés
6- * 2 Unité UBubbleSort
7- * 3 Exemple d'emploi
8- * 4 Voir aussi
1+Le tri à bulle est un algorithme de tri simple.
92
103## Propriétés
114
12- * Très lent
13- * Adapté seulement pour trier des données en petite quantité
14- * Rapide seulement quand le tableau est presque trié
5+- Très lent
6+- Adapté seulement pour trier des données en petite quantité
7+- Rapide seulement quand le tableau est presque trié
158
169## Unité UBubbleSort
17-```
10+
11+``` pascal
1812unit UBubbleSort;
19-
20- interface
21-
22- type
23- // data type
24- TItemBubbleSort=integer;
25-
26- procedure BubbleSort( var a: array of TItemBubbleSort );
27-
28-
29- implementation
30-
31- procedure swap( var a, b:TItemBubbleSort );
32- var
33- temp : TItemBubbleSort;
34- begin
35- temp := a;
36- a := b;
37- b := temp;
38- end;
39-
40-
41- procedure BubbleSort( var a: array of TItemBubbleSort );
42- var
43- n, newn, i:integer;
44- begin
45- n := high( a );
46- repeat
47- newn := 0;
48- for i := 1 to n do
13+
14+interface
15+
16+type
17+ // data type
18+ TItemBubbleSort=integer;
19+
20+procedure BubbleSort( var a: array of TItemBubbleSort );
21+
22+implementation
23+
24+procedure swap( var a, b:TItemBubbleSort );
25+var
26+ temp : TItemBubbleSort;
27+begin
28+ temp := a;
29+ a := b;
30+ b := temp;
31+end;
32+
33+procedure BubbleSort( var a: array of TItemBubbleSort );
34+var
35+ n, newn, i:integer;
36+begin
37+ n := high( a );
38+ repeat
39+ newn := 0;
40+ for i := 1 to n do
41+ begin
42+ if a[ i - 1 ] > a[ i ] then
4943 begin
50- if a[ i - 1 ] > a[ i ] then
51- begin
52- swap( a[ i - 1 ], a[ i ]);
53- newn := i ;
54- end;
55- end ;
56- n := newn;
57- until n = 0;
58- end;
59-
60- end.
44+ swap( a[ i - 1 ], a[ i ]);
45+ newn := i ;
46+ end;
47+ end ;
48+ n := newn;
49+ until n = 0;
50+end;
51+
52+end.
6153```
6254
6355## Exemple d'emploi
64-```
56+
57+``` pascal
6558uses
66- UBubbleSort
67- ...
68-
69- var
70- a: array[0..100] of integer;
71- begin
72- ...
73- BubbleSort(a);
74- ...
59+ UBubbleSort
60+ ...
61+
62+var
63+ a: array[0..100] of integer;
64+begin
65+ ...
66+ BubbleSort(a);
67+ ...
7568```
7669
7770## Voir aussi
7871
79- * [COMP1 Réviser et Apprendre : Tri à bulle](<https://www.youtube.com/watch?v=DXO-nqATduU%7C>)
72+- \[<https://www.youtube.com/watch?v=DXO-nqATduU>\| COMP1 Réviser et Apprendre : Tri à bulle\]
8073
8174---
82-*From the Free Pascal wiki, page "Bubble sort/fr", as the Internet Archive kept it on 2023-03-30. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
75+*From the Free Pascal wiki, page "Bubble sort/fr", as it stood on 2020-02-10 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history