Sign in Join
Wiki copytemporary

Bubble sort/fr: what changed

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

OldNewLine
1-Le tri à bulle est un algorithme de tri simple.
1+Le tri à bulle est un algorithme de tri simple.
22
3+## Contents
4+
5+ * 1 Propriétés
6+ * 2 Unité UBubbleSort
7+ * 3 Exemple d'emploi
8+ * 4 Voir aussi
9+
310## Propriétés
411
5-- Très lent
6-- Adapté seulement pour trier des données en petite quantité
7-- Rapide seulement quand le tableau est presque trié
12+ * Très lent
13+ * Adapté seulement pour trier des données en petite quantité
14+ * Rapide seulement quand le tableau est presque trié
815
916## Unité UBubbleSort
10-
11-``` pascal
17+```
1218unit UBubbleSort;
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
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
4349 begin
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.
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.
5361```
5462
5563## Exemple d'emploi
56-
57-``` pascal
64+```
5865uses
59- UBubbleSort
60- ...
61-
62-var
63- a: array[0..100] of integer;
64-begin
65- ...
66- BubbleSort(a);
67- ...
66+ UBubbleSort
67+ ...
68+
69+ var
70+ a: array[0..100] of integer;
71+ begin
72+ ...
73+ BubbleSort(a);
74+ ...
6875```
6976
7077## Voir aussi
7178
72-- \[<https://www.youtube.com/watch?v=DXO-nqATduU>\| COMP1 Réviser et Apprendre : Tri à bulle\]
79+ * [COMP1 Réviser et Apprendre : Tri à bulle](<https://www.youtube.com/watch?v=DXO-nqATduU%7C>)
7380
7481---
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).*
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).*

Back to history