Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Reverse-a-string/Oberon/reverse-a-string.oberon
Normal file
28
Task/Reverse-a-string/Oberon/reverse-a-string.oberon
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
MODULE reverse;
|
||||
|
||||
IMPORT Out, Strings;
|
||||
|
||||
VAR s: ARRAY 12 + 1 OF CHAR;
|
||||
|
||||
PROCEDURE Swap(VAR c, d: CHAR);
|
||||
VAR oldC: CHAR;
|
||||
BEGIN
|
||||
oldC := c; c := d; d := oldC
|
||||
END Swap;
|
||||
|
||||
|
||||
PROCEDURE Reverse(VAR s: ARRAY OF CHAR);
|
||||
VAR len, i: INTEGER;
|
||||
BEGIN
|
||||
len := Strings.Length(s);
|
||||
FOR i := 0 TO len DIV 2 DO
|
||||
Swap(s[i], s[len - 1 - i])
|
||||
END
|
||||
END Reverse;
|
||||
|
||||
BEGIN
|
||||
s := "hello, world";
|
||||
Reverse(s);
|
||||
Out.String(s);
|
||||
Out.Ln
|
||||
END reverse.
|
||||
Loading…
Add table
Add a link
Reference in a new issue