Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
8
Task/Generic-swap/Delphi/generic-swap-1.delphi
Normal file
8
Task/Generic-swap/Delphi/generic-swap-1.delphi
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
procedure Swap_T(var a, b: T);
|
||||
var
|
||||
temp: T;
|
||||
begin
|
||||
temp := a;
|
||||
a := b;
|
||||
b := temp;
|
||||
end;
|
||||
26
Task/Generic-swap/Delphi/generic-swap-2.delphi
Normal file
26
Task/Generic-swap/Delphi/generic-swap-2.delphi
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
program GenericSwap;
|
||||
|
||||
type
|
||||
TSwap = class
|
||||
class procedure Swap<T>(var left, right: T);
|
||||
end;
|
||||
|
||||
class procedure TSwap.Swap<T>(var left, right: T);
|
||||
var
|
||||
temp : T;
|
||||
begin
|
||||
temp := left;
|
||||
left := right;
|
||||
right := temp;
|
||||
end;
|
||||
|
||||
var
|
||||
a, b : integer;
|
||||
|
||||
begin
|
||||
a := 5;
|
||||
b := 3;
|
||||
writeln('Before swap: a=', a, ' b=', b);
|
||||
TSwap.Swap<integer>(a, b);
|
||||
writeln('After swap: a=', a, ' b=', b);
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue