Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program lab6;
- type
- Word = string[100];
- List = array [1..64] of Word;
- procedure SortWords(var item: List; count:integer);
- procedure qs(l, r: integer; var it:List);
- var
- i, j: integer;
- x, y: Word;
- begin
- i := l; j := r;
- x := it[(l+r) div 2];
- repeat
- while it[i] < x do i := i+1;
- while x < it[j] do j := j-1;
- if i<=j then
- begin
- y := it[i];
- it[i] := it[j];
- it[j] := y;
- i := i+1; j := j-1;
- end;
- until i>j;
- if l<j then qs(l, j, it);
- if l<r then qs(i, r, it);
- end;
- begin
- qs(1, count, item);
- end;
- var count:integer;
- wordlist:List;
- i:integer;
- begin
- Write('Words count: ');
- Readln(count);
- for i:=1 to count do
- readln(wordlist[i]);
- SortWords(wordlist,count);
- for i:=1 to count do
- write(wordlist[i]+' ');
- readln();
- end.
Add Comment
Please, Sign In to add comment