0% found this document useful (0 votes)
3 views4 pages

S2 Informatique1

The document provides instructions for working with arrays and matrices in programming, including declaration, reading, writing, and performing operations such as sum, average, maximum, minimum, and searching for values. It also covers merging arrays, transforming between arrays and matrices, and performing matrix addition and multiplication. Additionally, it includes methods for permuting rows and columns and extracting diagonal elements.

Uploaded by

tebbaladel25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

S2 Informatique1

The document provides instructions for working with arrays and matrices in programming, including declaration, reading, writing, and performing operations such as sum, average, maximum, minimum, and searching for values. It also covers merging arrays, transforming between arrays and matrices, and performing matrix addition and multiplication. Additionally, it includes methods for permuting rows and columns and extracting diagonal elements.

Uploaded by

tebbaladel25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Berrabah Anes( @the_actual_lloyd_b)

Les Tableaux (Arrays)


Description Instruction
Declaration Var
N : la taille du tableau T:array [1..N] of integer;
Integer : le type (integer, char, i: integer;
sting,bool,real)
La lecture For i :=1 to n do
En utilisant la boucle pour Read (T[i]) ;
L’écriture For i :=1 to n do
En utilisant la boucle pour Write (T[i]) ;
La somme du tableau S:=0;
For i :=1 to n do
Var S:=S+t[i];
S: integer;
Write(‘la somme de tableau est’, s) ;
La somme conditionnel S:=0;
For i :=1 to n do
If(condition sur S)then
S:=S+t[i];
Write(‘la somme de tableau est’, s) ;
Moyenne (apres la somme) Moy= S/ N ;
Var Write(‘Moyenne de tableau est’, Moy) ;
Moy:real;

Maximum Max:=t[1];
Var For i :=1 to n do
Max :integer ; If(t[i]>Max)then
Max:=t[i];
Write(‘Maximum de tableau est’, Max) ;
Minimum Min:=t[1];
Var For i :=1 to n do
Min :integer ; If(t[i]<Min)then
Min:=t[i];
Write(‘Mininmum de tableau est’, Min) ;
Recherche Cpt:=0;
Val,Cpt : integer ; Read(Val);
For i :=1 to n do
If(t[i]=Val)then
Cpt:=Cpt+1;
If (Cpt =0) then
Write(Val , ‘exist pas dans Tableau’)
else
Write(Val , ‘exist dans Tableau’ , Cpt,
‘fois’) ;
Berrabah Anes( @the_actual_lloyd_b)

Fusionner deux tableaux K:=1;


Var For i:=1 to N do
T2:array [1..N] of integer; Begin
T3:array [1..M] of integer; T3[k]:=T[i]
K:integer; K:=k+1;
End;
For i:=1 to N do
Begin
T3[k]:=T[i];
K:=k+1;
End;

Les Matrices(Arrays)
Description Instruction
Declaration Var
N : nombre de lignes Mat:array [1..N,1..M] of integer;
M : nombre de colones i,j: integer;

Integer : le type (integer, char,


sting,bool,real)
La lecture Read(N,M)
En utilisant deux boucle pour For i :=1 to N do
For j :=1 to M do
Read (Mat[i,j]) ;

L’écriture For i :=1 to N do


En utilisant deux boucle pour begin
Writeln(‘ ’);
For j :=1 to M do
write(Mat[i,j],’ ‘) ;
end;
La somme du Matrice S:=0;
For i :=1 to N do
Var For j :=1 to M do
S: integer; S:=S+ Mat[i,j];

Write(‘la somme de Matrice est’, s) ;


Moyenne (apres la somme) Moy= S/ N ;
Var Write(‘Moyenne de Matrice est’, Moy) ;
Moy:real;

Maximum Max:= Mat[1,1];


Var For i :=1 to N do
Berrabah Anes( @the_actual_lloyd_b)
Max :integer ; For j :=1 to M do
If(Mat[i,j]>Max)then
Max:= Mat[i,j] ;
Write(‘Maximum de matrice est’, Max) ;
Minimum Max:= Mat[1,1];
Var For i :=1 to N do
Min :integer ; For j :=1 to M do
If(Mat[i,j]<Min)then
Max:= Mat[i,j] ;
Write(‘Minimum de matrice est’, Min) ;
Recherche
Val,Cpt : integer ; Cpt:=0;
Read(Val);
For i :=1 to N do
For j :=1 to M do
If( Mat[i,j] =Val)then
Cpt:=Cpt+1;
If (Cpt =0) then
Write(Val , ‘exist pas’)
else
Write(Val , ‘exist dans’ , Cpt, ‘fois’) ;

Transformation de matrice a un tableau K :1 ;


Var For i :=1 to N do
T:array [1..1000] of integer; For j :=1 to M do
k:integer ; Begin
T[k]:=Mat[i,j];
K:=k+1
End;

Transformation de tableau a une matrice K :1 ;


Var For i :=1 to N do
T:array [1..1000] of integer; For j :=1 to M do
k:integer ; Begin
Mat[i,j]:= T[k];
K:=k+1
End;

Somme de deux matrices For i :=1 to N do


var For j :=1 to M do
Mat2,Mat3 :array [1..N,1..M] of integer; Mat3[i,j]:= Mat2[i,j]+ Mat[i,j];
Berrabah Anes( @the_actual_lloyd_b)
Produit de deux matrice for i:=1 to N do
Mat2,Mat3 :array [1..N,1..N] of integer; for j:=1 to N do
K:integer; begin
mat3[i,j]:=0;
for k:=1 to N do
Mat3[i,j]:=Mat3[i,j]+Mat[i,k]*Mat2[k,j];
end;
end;
Permutation de deux colones Read(c1,c2);
Val for i:=1 to N do
C1, C2,X : integer ; begin
X:=Mat[i,c1];
Mat[i,c1]:=Mat[i,c2];
Mat[i,c2]:=X;
End;
Permutation de deux lignes Read(L1,L2);
Val for i:=1 to M do
L1 ,L2,X : integer ; begin
X:=Mat[L1,i];
Mat[L1,i]:=Mat[L2,i];
Mat[L2,i]:=X;
End;
Diagonal For i :=1 to N do
For j :=1 to M do
If(i = j) then
write(Mat[i,j],’ ‘) ;

You might also like