CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
36
Task/Search-a-list/Delphi/search-a-list.delphi
Normal file
36
Task/Search-a-list/Delphi/search-a-list.delphi
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
program Needle;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses
|
||||
SysUtils, Classes;
|
||||
|
||||
var
|
||||
list: TStringList;
|
||||
needle: string;
|
||||
ind: Integer;
|
||||
begin
|
||||
list := TStringList.Create;
|
||||
try
|
||||
list.Append('triangle');
|
||||
list.Append('fork');
|
||||
list.Append('limit');
|
||||
list.Append('baby');
|
||||
list.Append('needle');
|
||||
|
||||
list.Sort;
|
||||
|
||||
needle := 'needle';
|
||||
ind := list.IndexOf(needle);
|
||||
if ind < 0 then
|
||||
raise Exception.Create('Needle not found')
|
||||
else begin
|
||||
Writeln(ind);
|
||||
Writeln(list[ind]);
|
||||
end;
|
||||
|
||||
Readln;
|
||||
finally
|
||||
list.Free;
|
||||
end;
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue