tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
25
Task/Range-extraction/DWScript/range-extraction.dwscript
Normal file
25
Task/Range-extraction/DWScript/range-extraction.dwscript
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
procedure ExtractRanges(const values : array of Integer);
|
||||
begin
|
||||
var i:=0;
|
||||
while i<values.Length do begin
|
||||
if i>0 then
|
||||
Print(',');
|
||||
Print(values[i]);
|
||||
var j:=i+1;
|
||||
while (j<values.Length) and (values[j]=values[j-1]+1) do
|
||||
Inc(j);
|
||||
Dec(j);
|
||||
if j>i then begin
|
||||
if j=i+1 then
|
||||
Print(',')
|
||||
else Print('-');
|
||||
Print(values[j]);
|
||||
end;
|
||||
i:=j+1;
|
||||
end;
|
||||
end;
|
||||
|
||||
ExtractRanges([ 0, 1, 2, 4, 6, 7, 8, 11, 12, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
||||
25, 27, 28, 29, 30, 31, 32, 33, 35, 36,
|
||||
37, 38, 39]);
|
||||
Loading…
Add table
Add a link
Reference in a new issue