0

hello guys,
i'm facing a difficulty in creating a matrix in pascal, the compiler keeps posting the messeges illegal qualifier at the line 28,7 where i wrote read(M[i,j]), and telling types mismatch coz i declared M is from type Matrice that i defined and then in the procedure Lect2d i declared it an array of longint but i did this bcoz i can't declare it as Matrice because when i'll use in other programmes whee Matrice is an "unknown" type it won't work, here's the code, PLEASE help what to do??

program test_lect2d;

uses crt;
const Max1=2000000000;
             Max2=2000000000;
type  Matrice= array of [1..Max1,1..Max2] of longint;
var   M:Matrice;
            T1,T2: longint;

procedure lect2d(var M: array of longint; Var T1,var T2: longint);

{****************************************************************************}

{cette pocedure lit un tableau a deux dimension dont les elements sont
                              des entiers }

{****************************************************************************}

var i,j: longint;
Begin
writeln('donnez les dimentions de votre matrice');
readln(T1);
readln(T2);
for i := 1 to T1 do
    for j :=1 to T2 do
       begin
       writeln('M[',i,',',j,']=');
       read(M[i,j]);
       end;
end;

BEGIN
lect2d(M,T1,T2);
readln;
END.
3
Contributors
2
Replies
22
Views
9 Months
Discussion Span
Last Post by ddanbe
0

I'm not sure how any of that compiled. Here's what I was able to do in FreePascal.
Disclaimer: I am not a Pascal programmer, but Google and basic knowledge of imperative languages are helpful.

program test_lect2d;
uses crt;
const Max1=4096;
         Max2=4096;
type  Matrice= array [1..Max1,1..Max2] of longint;
var   MyMatrix:Matrice;
        T1,T2: longint;

procedure lect2d(var M: Matrice; Var T1,T2: longint);
{****************************************************************************}
{cette pocedure lit un tableau a deux dimension dont les elements sont
                          des entiers }
{****************************************************************************}
var i,j: longint;
Begin
    writeln('donnez les dimentions de votre matrice');
    readln(T1);
    readln(T2);
    for i := 1 to T1 do
    for j :=1 to T2 do
       begin
           writeln('M[',i,',',j,']=');
           read(M[i,j]);
       end;
end;
BEGIN
    lect2d(MyMatrix,T1,T2);
    readln;
END.

Edited by Dean_5

2

Are you trying to map the whole world in one matrix?
2000000000x2000000000 = 4x10^18.

Votes + Comments
"I've got the whole world in my ..." page fault.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.