June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,49 @@
|
|||
MODULE RemoveDuplicates;
|
||||
|
||||
FROM STextIO IMPORT
|
||||
WriteLn;
|
||||
FROM SWholeIO IMPORT
|
||||
WriteInt;
|
||||
|
||||
TYPE
|
||||
TArrayRange = [1 .. 7];
|
||||
TArray = ARRAY TArrayRange OF INTEGER;
|
||||
|
||||
VAR
|
||||
DataArray, ResultArray: TArray;
|
||||
ResultIndex, LastResultIndex, Position: CARDINAL;
|
||||
IsNewNumber: BOOLEAN;
|
||||
|
||||
BEGIN
|
||||
(* Set the data. *);
|
||||
DataArray[1] := 1;
|
||||
DataArray[2] := 2;
|
||||
DataArray[3] := 2;
|
||||
DataArray[4] := 3;
|
||||
DataArray[5] := 4;
|
||||
DataArray[6] := 5;
|
||||
DataArray[7] := 5;
|
||||
|
||||
ResultArray[1] := DataArray[1];
|
||||
LastResultIndex := 1;
|
||||
Position := 1;
|
||||
WHILE Position < HIGH(DataArray) DO
|
||||
INC(Position);
|
||||
IsNewNumber := TRUE;
|
||||
ResultIndex := 1;
|
||||
WHILE (ResultIndex <= LastResultIndex) AND IsNewNumber DO
|
||||
IF DataArray[Position] = ResultArray[ResultIndex] THEN
|
||||
IsNewNumber := FALSE;
|
||||
END;
|
||||
INC(ResultIndex);
|
||||
END;
|
||||
IF IsNewNumber THEN
|
||||
INC(LastResultIndex);
|
||||
ResultArray[LastResultIndex] := DataArray[Position];
|
||||
END
|
||||
END;
|
||||
FOR ResultIndex := 1 TO LastResultIndex DO
|
||||
WriteInt(ResultArray[ResultIndex], 1);
|
||||
WriteLn;
|
||||
END;
|
||||
END RemoveDuplicates.
|
||||
Loading…
Add table
Add a link
Reference in a new issue