mirror of
https://github.com/vishapoberon/oberonbyexample.git
synced 2026-04-05 21:02:25 +00:00
intro to arrays with matrix example
This commit is contained in:
parent
b58c9c6737
commit
290ea11c03
2 changed files with 52 additions and 0 deletions
42
arrays/Arrays.Mod
Normal file
42
arrays/Arrays.Mod
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
MODULE arrays;
|
||||
|
||||
IMPORT Out;
|
||||
|
||||
VAR
|
||||
tmp : INTEGER;
|
||||
matrix : ARRAY 3 OF ARRAY 3 OF INTEGER;
|
||||
i, v, k : INTEGER;
|
||||
|
||||
BEGIN
|
||||
v := 1;
|
||||
FOR i := 0 TO LEN(matrix) - 1 DO
|
||||
FOR k := 0 TO LEN(matrix[i]) - 1 DO
|
||||
matrix[i][k] := v;
|
||||
INC(v);
|
||||
END;
|
||||
END;
|
||||
|
||||
FOR i := 0 TO LEN(matrix) - 1 DO
|
||||
FOR k := 0 TO LEN(matrix[i]) - 1 DO
|
||||
Out.Int(matrix[i][k], 0); Out.String(" ");
|
||||
END;
|
||||
Out.Ln;
|
||||
END;
|
||||
|
||||
FOR i := 0 TO LEN(matrix) - 1 DO
|
||||
FOR k := i + 1 TO LEN(matrix[i]) - 1 DO
|
||||
tmp := matrix[i][k];
|
||||
matrix[i][k] := matrix[k][i];
|
||||
matrix[k][i] := tmp;
|
||||
END;
|
||||
END;
|
||||
|
||||
Out.Ln; Out.Ln;
|
||||
|
||||
FOR i := 0 TO LEN(matrix) - 1 DO
|
||||
FOR k := 0 TO LEN(matrix[i]) - 1 DO
|
||||
Out.Int(matrix[i][k], 0); Out.String(" ");
|
||||
END;
|
||||
Out.Ln;
|
||||
END;
|
||||
END arrays.
|
||||
10
arrays/Makefile
Normal file
10
arrays/Makefile
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
VOC = /opt/voc/bin/voc
|
||||
|
||||
all:
|
||||
$(VOC) -m Arrays.Mod
|
||||
|
||||
clean:
|
||||
rm *.c
|
||||
rm *.h
|
||||
rm *.o
|
||||
rm *.sym
|
||||
Loading…
Add table
Add a link
Reference in a new issue