Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program exercice2;
- Uses Wincrt;
- Type
- tab = Array [1..99,1..99] Of Integer;
- tab2 = Array [1..99] Of Integer;
- Var
- t: tab;
- n: Integer;
- Procedure remplir (Var t:tab;Var n:Integer);
- Var
- i,j: Integer;
- Begin
- Repeat
- Write ('Saisir N: ');
- Readln (n);
- Until (n Mod 2<>0);
- For i:=1 To n Do
- For j:=1 To n Do
- Begin
- Write ('T[',i,',',j,'] : ');
- Readln (t[i,j]);
- End;
- End;
- Procedure ligne (t:tab;n:Integer;Var l:tab2);
- Var
- i,j,x: Integer;
- Begin
- For i:=1 To n Do
- Begin
- x := 0;
- For j:=1 To n Do
- x := x+t[i,j];
- l[i] := x;
- End;
- End;
- Procedure colone (t:tab;n:Integer;Var c:tab2);
- Var
- i,j,x: Integer;
- Begin
- For i:=1 To n Do
- Begin
- x := 0;
- For j:=1 To n Do
- x := x+t[j,i];
- c[i] := x;
- End;
- End;
- Function vligne (l:tab2;n:Integer): Boolean;
- Var
- i: Integer;
- test: Boolean;
- Begin
- i := 0;
- Repeat
- i := i+1;
- test := l[i]=l[i+1];
- Until (test=False) Or (i=n-1);
- vligne := test;
- End;
- Procedure diago (t:tab;n:Integer;Var d:tab2);
- Var
- i,j,x: Integer;
- Begin
- j := 0;
- x := 0;
- For i:=1 To n Do
- Begin
- j := j+1;
- x := x+t[i,j];
- d[1] := x;
- End;
- j := n;
- x := 0;
- For i:=n DownTo 1 Do
- Begin
- x := x+t[i,j];
- j := j-1;
- End;
- d[2] := x;
- End;
- Procedure matrice (t:tab;n:Integer);
- Var
- l,c,d: tab2;
- i: Integer;
- test: Boolean;
- Begin
- ligne (t,n,L);
- colone (t,n,c);
- diago (t,n,d);
- test:=false;
- if d[1]=d[2] Then
- test:=True;
- If vligne(L,n) And vligne(c,n) and test Then
- Writeln ('La matrice est magique');
- End;
- Begin
- remplir (T,n);
- matrice (T,n);
- End.
Add Comment
Please, Sign In to add comment