17 lines
601 B
Text
17 lines
601 B
Text
include c:\cxpl\codes;
|
|
def IntSize = 4; \number of bytes in an integer
|
|
int Matrix, Size, I, J;
|
|
|
|
[Text(0, "Size: "); Size:= IntIn(0);
|
|
Matrix:= Reserve(Size*IntSize); \reserve memory for 2D integer array
|
|
for I:= 0 to Size-1 do
|
|
Matrix(I):= Reserve(Size*IntSize);
|
|
for J:= 0 to Size-1 do \make array an identity matrix
|
|
for I:= 0 to Size-1 do
|
|
Matrix(I,J):= if I=J then 1 else 0;
|
|
for J:= 0 to Size-1 do \display the result
|
|
[for I:= 0 to Size-1 do
|
|
[IntOut(0, Matrix(I,J)); ChOut(0, ^ )];
|
|
CrLf(0);
|
|
];
|
|
]
|