Prog_2 course- 2014 
2 bytes team 
Kinan keshkeh 
IT Engineering-Damascus University 
3rd year
Let’s Remember!! SomeOf Prog_1 :D
Program 2Bytes_pro; 
Uses wincrt; 
Var k,x,y,z :integer; 
Procedure proc1(a:integer; var b:integer ;) 
var i,x: integer; 
Begin 
i:=10; x:=7; y:=12; a:=2; b:=4; 
end; 
Begin 
x:=3; y:=5; proc1(k,z); 
Writeln(„z=„,z); 
Writeln(„k=„,k); 
Writeln(„x=„,x); 
Writeln(„y=„,y); 
Writeln(„i=„,i); 
End. 
+1 
+1 
+1 
+1 
+1 
{ z=4 } 
{Random value often be zero} 
{ x=3 } 
{ y=12 } 
{ error }
In procedures and functions There are four types of variables : 
1.General Variables : are variables that are written at the top of the program befor all procedures and functions and we can see it and deal with it by all procedures and functions in the main program (like : k , x , y , z) . 
2.Local Variables : are variables that are declared in the statements part within procedure or function and we can‟t see it and deal with it outside that procedures (like : i , x ) . 
3.Formality Variables : are variables that appear in the header of procedure or function and it is formality and is not reserved place for it in memory (like a , b ) 
 we have two types of formality variables 
1) input variables : Keeps the value entered by after the completion of the procedural ( like : a) 
2)output variables : Keeps the value obtained by the procedure. And we writes before it the reserved word (var) (like : b ) 
4.Actual Variables : are variables that main program pass it to procedure or function during a summons and it agree formality variables in number and type (like : k , z)
Notes : 
Local variables have priority from general variables in the same Field of vision ( ايؤرنا لاجي ) ( like : x) 
 Execution always start form (begin) by the main program 
 in string : 
var : name , lname : string ; 
begin writeln(„enter the name and lname „); 
readln(name , lname); 
writeln(name); 
writeln(lname); 
End. 
Ahmed 
Ali 
Inputs : 
Ahmed Ali 
X nothing 
outputs 
name); 
readln(lname); 
+1
SETS 
A П B 
A 
B
What is a DiscreteType?? 
Discrete Data Type: 
Integer 
boolean 
char 
Enumerated 
Day=(sat,sun,mon,tu,wed,th,fri) 
Like..
Definition 
The SET is a Data Structure which contain discrete type elements .. 
Doesn‟t have index.!! 
<Nameof varible > :Set of < discrete type > 
We can‟t define the set as this form : 
S : Set of Integer; 
Because set can have 256 components at most and all its component values should be in rang 0 .. 255 .
Ex: 
•S1 : Set of 1..100; 
•S2 : Set of „a‟..‟z‟; 
•S : Set of Days; 
•S : Set of 66..256; 
•S: set of char ; 
{True} 
{True} 
{True} 
{False} 
+1 
{True}
Set Handling 
Var: 
s1:set of 0..255; 
S2,s3:set of 40..100; 
S4:set of „a‟..‟z‟;
S1 := [ 55, 80, 99, 80, 600, 41, 44..55]; 
Isn‟t added 
S1: 
41 44..55 80 99
S1 : 
S1 := [];
S2 := [200,20]; 
S2: 
40..100 
“NO Change”
S4 := [‘B’,’A’,’c’,’a’]; 
S4: 
„a‟ „c‟
S4 := [I,k]; 
Var I,k:integer; 
i:=1; k:=k+1; 
+1 
S4: 
Compile Error !!
S1 := [I,j]; 
Var I,j:integer; 
i:=1; j:=i*9; 
+1 
S1: 
1,9
i, j : integer; i := 1; j := i-1; S1 := [i, j]; S1 := S1 + [i*2]; 
S1: 
0,1,2 
+1
S1:=S4; 
+1 
Error 
Ya fahmaneen !! :D
Operation 
•To put a value in it , we use [value] . 
•The operations on Sets : 
⋂ ⇔ * 
⋃ ⇔ + 
/ ⇔ - 
⊆ ⇔ <= 
⊇ ⇔ >= 
∈ ⇔ in
Program SetsOperator; Var A0 : set of 1..15; A1 : set of 1..10; A2 : set of 5..15; i : integer; Begin A1 := [1..10]; A2 := [5..15]; A0 := A1*A2; {A0=[5..10]} A0 := A1+A2; {A0=[1..15]} A0 := A1-A2; {A0=[1..4]} A0 := A0-[1]; {A0=[2..4]}
A1 := [2,3]; 
A2 := [1,2,3,4,5]; 
if (A1 <= A2) then {or (A2 >= A1)} 
writeln ('A1 is a subset of A2'); 
readln (i); 
if (i in A1) then 
writeln (i,' is in A1') 
else 
writeln (i,' is not in A1'); 
End;
True statement 
A0, A1 : Set of 1..15; A : boolean; A0 := [1, 2]; A1 := [2, 4]; A0 := A0 – [77]; A := A1 >= A0; A := 1 in A0;
Const Sets 
Type 
Digits = set of 0..9; 
Const 
HexD : set of '0'..'z‘ = 
['0'..'9', 'A'..'F', 'a'..'f']; 
ED : Digits = [0, 2, 4, 6, 8]; 
Var 
d : Digits; 
Begin 
d := [8]; 
d := ED; {d=[0,2,4,6,8]} 
ED:=ED+[9]; 
ED:=d; 
End. 
+1 
Error .. Fateh 3eoonk !!
Enum Set 
Type 
Day = (sun,mon,….,sat); 
Name=(koko,soso,fofo,fifi); 
Var 
days: Set of Day; 
N:set of Name 
Begin 
Days:=[sun..sat]; 
N:=[KOKO,SOSO]; 
End.
Read & Print Sets :
Program Test(); Type SInt = Set of 1..150 ; SCh = Set of ‘0’..’z’; Var S1 : SInt; S2 : SCh; Slen : Integer; Begin Readln(Slen); ReadsetI(S1 , Slen); ReadsetC(S2 , Slen); PrintsetI(S1 , Slen); PrintsetC(S2 , Slen); Readln; End.
Read Integer Sets 
Procedure ReadsetI (var S:SInt; L:integer) ; 
var 
i, x : integer; 
Begin 
s:=[]; 
For i:=1 to L do 
begin 
Read(x); 
S := S + [x]; 
end; 
End;
Read Char Sets 
Procedure ReadsetC (var S:SCh; L:integer) ; var i, x : Char; Begin s:=[]; For i:=1 to L do begin Read(x); S := S + [x]; end; End;
Print Integer Sets Using While Loop: 
Procedure PrintsetI (S : SInt) ; 
var 
I : Integer; 
Begin 
I := 0; 
While ( S <> []) do 
If (I in S) then 
begin 
Writeln(I); 
S := S – [I]; 
end; 
I := I + 1; 
End;
Print Integer Sets Using For Loop 
Procedure PrintsetI (S : SI) ; var I : Integer; Begin For I:=1 to 32700 do Begin If (I in S) then Begin Writeln(I); S := S – [I]; End; If (S = []) then I := 32700; End; End;
Exercise : 
يرى في يؼهذ يا إػطاء دوراخ في يادذي انرياضياخ وانهغح الإ كَهيسيح 
يؼطى كم طانة ػ ذُ ذسجيهه في ان ؼًهذ رقى فريذ يحصىر تي 1..100 فإرا ػه دً أ ػذد انطلاب في كم يادج لا يرجاوز 50 طانة 
ان طًهىب كراتح تر اَيج ػاو تاسرخذاو الاجرائياخ وان جً ىًػاخ ورنك 
نهقياو تان هًاو انرانيح : 
. 
1 ذشكيم يج ىًػح نطلاب انرياضياخ ويج ىًػح نطلاب انهغح 
الإ كَهيسيح )إدخال ػ اُصر ان جً ىًػح ( 
. 
2 إجراء نطثاػح ػ اُصر ان جً ىًػح 
. 
3 إجراء لإػطاء يج ىًػح تأرقاو انطلاب ان سًجهي تان اًدذي . 
4 قررخ إدارج ان ؼًهذ ذخفيض ػذد انطلاب ورنك تالاسرغ اُء ػ ػذد 
يحذد ي هُى يذخم ي نىحح ان فًاذيح ػهى أ يرى اخريار أرقاو 
انطلاب ان فًصىني تشكم ػشىائي وان طًهىب كراتح إجراء ن قُم 
أرقاو انطلاب ان فًصىني إنى يج ىًػح جذيذج 
. 
5 وضغ أرقاو انطلاب ان فًصىني ض شؼاع
Program prog2byte_team; 
Uses wincrt; 
Type students=set of 1..100; 
numbers=array[1..50] of 1..100; 
Var seng,smath : students; 
Procedure inputset(var s : students; m:integer); 
Var i,x: integer; 
Begin 
s:=[ ]; 
i:=0; 
While (i<m) do 
begin 
writeln(„input students number „); 
readln(x); 
if (x in s) then 
writeln(„ you input this number befor please enter 
another number „) 
else 
begin 
i:=i+1; 
s:=s+[x]; 
end; 
end; 
End; 
numbers of students
Procedure printset(s :students); 
Var i:integer; 
Begin 
i:=1; 
While (s<>[ ]) do 
begin 
if (i in s) then 
begin 
write(i:5); 
s:=s-[ i ]; 
end; 
i:=i+1; 
end; 
writeln; 
End;
Procedure bothsub(s1,s2 : students; var s3: students); 
Begin 
s3:=s1*s2; 
End;
Procedure deletestd(var s,n : students); 
Var k,i,x ; integer; 
Begin 
n:= [ ]; 
Randomize; 
i:=0; 
Writeln(„enter the number you want to go throw out „); 
Readln(x); 
While (i<x) do 
begin 
k:= random(100) + 1; 
if ( k in s ) then 
begin 
s:=s – [ k ]; 
seng:= seng – [ k ]; 
smath:=smath – [ k ]; 
i:=i+1; 
n:=n + [ k ]; 
end; 
end; 
End; 
بلاطنا حػىًجي 
ان فًصىني يج ىًػح 
انرقاطغ 
:Randomize يقىو ترىنيذ 
أرقاو ػشىائيح أػر اًدا ػهى 
ساػح ان ظُاو 
:Random(100)=0..99; 
Random(100)+1=1..100
Procedure setinArray(s: students; var a: numbers ; var k: integer); 
Var i : integer; 
Begin 
K:=0; 
For i:=1 to 100 do 
If (i in s) then 
begin 
k:=k+1; 
a[k]:=i; 
end; 
End; 
ي أجم اسرذػاء 
انشؼاع في انثر اَيج 
انرئيسي
Var nmath,neng,k,i :integer; 
Aunaccepted : numbers; 
Sunaccepted,sboth : students; 
Begin 
Writeln(„enter the number of math students „); 
Readln(nmath); 
Inputset(smath,nmath); 
Writeln(„enter the number of English students „); 
Readln(neng); 
Inputset(seng,neng); 
Bothsub(smath , seng , sboth); 
Printset(sboth); 
Deletestd(sboth,Sunaccepted); 
Printset(Sunaccepted); 
setinArray(Sunaccepted,Aunaccepted,k); 
For i:=1 to k do 
Writeln(Aunaccepted[i]:5); 
Readln; 
End.
Homework: 
Creat and read two arrays of student numbers, student numbers in Prog and in English. 
-We want to know the students numbers at the two subjects..?! 
-what are the student numbers at the Prog and Not at English ?? 
+10 point
Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 
2 bytes team
Revision Practise
Ques: 
write a programme DO: 
1-Read An Array 2-Print An Array//Proce 
3-function to find the min elem in the array 
4-Procedure to find the Sum array(of the tow arrays). 
5- Multi array 
Write the Main Program..
Programme P-Matrix; 
Const nMax=20; mMax=20; 
Type Matrix=array[1..nmax,1..mmax] of real; 
Var A,B,Add,mult :Matrix; 
n1,n2 :1..nmax; 
m1,m2 :1..mmax; 
min: integer;
Procedure ReadMat(Var: n:1..nmax;var m:1..mmax; var A:matrix); 
Var i,j:integer; 
begin 
writeln(„enter the first Dimention of matrix< ‟ ,nmax); 
Readln(n); 
writeln(„enter the second Dimention of matrix< ‟ ,mmax); 
Readln(m); 
for i:=1 to n do 
begin 
for j:=1 to m do read(A[I,j]); {hint} 
readln; {hint} 
end; 
end;
Procedure WriteMat(Var: n:1..nmax;var m:1..mmax; var A:matrix); 
Var i,j:integer; 
begin 
for i:=1 to n do 
begin 
for j:=1 to m do write(A[i,j],‟ ‟); 
writeln; 
end; 
end;
Function MinOfMatrix(n:1..nmax,m:1..mmax;A:matrix):real 
Var i,j:integer; min:real; 
begin 
min:=A[1,1]; 
For i:=1 to n do 
for j:=1 to m do 
if (A[i,j]<min) then 
min:=A[i,j]; 
MinOfMatrix:=min; 
end;
Procedure Add_Tow_Matrix(n1,n2:1..nmax; m1,m2:1..mmax; var n3:1..nmax; var m3:1..mmax; var c:Matrix); 
Var i,j:integer; 
begin 
if(n1<>n2)or(m1<>m2) then 
writeln(„the addition is impossible‟); 
else 
begin 
n3:=n1; m3:=m1; 
for i:=1 to n3 do 
for j:=1 to m3 do 
C[i.j]:=A[i,j]+B[i,j]; 
end; 
end;
Procedure Mult_Tow_Matrix(n1,n2:1..nmax; m1,m2:1..mmax; var n3:1..nmax; var m3:1..mmax; var c:Matrix); 
Var i,j,k:integer; 
begin 
if(n1<>m2) then 
writeln(„the multi is impossible‟); 
else 
begin 
n3:=n2; m3:=m1; { A(m1,n1)*B(m2,n2)=C(m3,n3)} 
for i:=1 to n3 do 
for j:=1 to m3 do 
begin 
C[i,j]=0; 
for k:=1 to m2 
C[i.j]:= C[i.j] +A[i,k]*B[k,j]; 
end; 
end; 
end;
Begin 
ReadMat(n1,m1,A); WriteMat(n1,m1,A); 
ReadMat(n2,m2,B); WriteMat(n2,m2,B); 
writeln(„the minimum of the first Mat = ‟); 
min:=MinOfMatrix(n1,m1,A); writeln(min); 
Add_Tow_Matrix(n1.m1,n2,m2,A,B,n3,m3,Add); 
WriteMat(n3,m3,Add); 
Mult_Tow_Matrix(n1,n2,m1,m2,A,B, n3,m3,mult); 
WriteMat(n3,m3,mult); 
End;
Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 
2 bytes team

2Bytesprog2 course_2014_c1_sets

  • 1.
    Prog_2 course- 2014 2 bytes team Kinan keshkeh IT Engineering-Damascus University 3rd year
  • 2.
  • 3.
    Program 2Bytes_pro; Useswincrt; Var k,x,y,z :integer; Procedure proc1(a:integer; var b:integer ;) var i,x: integer; Begin i:=10; x:=7; y:=12; a:=2; b:=4; end; Begin x:=3; y:=5; proc1(k,z); Writeln(„z=„,z); Writeln(„k=„,k); Writeln(„x=„,x); Writeln(„y=„,y); Writeln(„i=„,i); End. +1 +1 +1 +1 +1 { z=4 } {Random value often be zero} { x=3 } { y=12 } { error }
  • 4.
    In procedures andfunctions There are four types of variables : 1.General Variables : are variables that are written at the top of the program befor all procedures and functions and we can see it and deal with it by all procedures and functions in the main program (like : k , x , y , z) . 2.Local Variables : are variables that are declared in the statements part within procedure or function and we can‟t see it and deal with it outside that procedures (like : i , x ) . 3.Formality Variables : are variables that appear in the header of procedure or function and it is formality and is not reserved place for it in memory (like a , b )  we have two types of formality variables 1) input variables : Keeps the value entered by after the completion of the procedural ( like : a) 2)output variables : Keeps the value obtained by the procedure. And we writes before it the reserved word (var) (like : b ) 4.Actual Variables : are variables that main program pass it to procedure or function during a summons and it agree formality variables in number and type (like : k , z)
  • 5.
    Notes : Localvariables have priority from general variables in the same Field of vision ( ايؤرنا لاجي ) ( like : x)  Execution always start form (begin) by the main program  in string : var : name , lname : string ; begin writeln(„enter the name and lname „); readln(name , lname); writeln(name); writeln(lname); End. Ahmed Ali Inputs : Ahmed Ali X nothing outputs name); readln(lname); +1
  • 6.
    SETS A ПB A B
  • 7.
    What is aDiscreteType?? Discrete Data Type: Integer boolean char Enumerated Day=(sat,sun,mon,tu,wed,th,fri) Like..
  • 8.
    Definition The SETis a Data Structure which contain discrete type elements .. Doesn‟t have index.!! <Nameof varible > :Set of < discrete type > We can‟t define the set as this form : S : Set of Integer; Because set can have 256 components at most and all its component values should be in rang 0 .. 255 .
  • 9.
    Ex: •S1 :Set of 1..100; •S2 : Set of „a‟..‟z‟; •S : Set of Days; •S : Set of 66..256; •S: set of char ; {True} {True} {True} {False} +1 {True}
  • 10.
    Set Handling Var: s1:set of 0..255; S2,s3:set of 40..100; S4:set of „a‟..‟z‟;
  • 11.
    S1 := [55, 80, 99, 80, 600, 41, 44..55]; Isn‟t added S1: 41 44..55 80 99
  • 12.
    S1 : S1:= [];
  • 13.
    S2 := [200,20]; S2: 40..100 “NO Change”
  • 14.
  • 15.
    S4 := [I,k]; Var I,k:integer; i:=1; k:=k+1; +1 S4: Compile Error !!
  • 16.
    S1 := [I,j]; Var I,j:integer; i:=1; j:=i*9; +1 S1: 1,9
  • 17.
    i, j :integer; i := 1; j := i-1; S1 := [i, j]; S1 := S1 + [i*2]; S1: 0,1,2 +1
  • 18.
    S1:=S4; +1 Error Ya fahmaneen !! :D
  • 19.
    Operation •To puta value in it , we use [value] . •The operations on Sets : ⋂ ⇔ * ⋃ ⇔ + / ⇔ - ⊆ ⇔ <= ⊇ ⇔ >= ∈ ⇔ in
  • 20.
    Program SetsOperator; VarA0 : set of 1..15; A1 : set of 1..10; A2 : set of 5..15; i : integer; Begin A1 := [1..10]; A2 := [5..15]; A0 := A1*A2; {A0=[5..10]} A0 := A1+A2; {A0=[1..15]} A0 := A1-A2; {A0=[1..4]} A0 := A0-[1]; {A0=[2..4]}
  • 21.
    A1 := [2,3]; A2 := [1,2,3,4,5]; if (A1 <= A2) then {or (A2 >= A1)} writeln ('A1 is a subset of A2'); readln (i); if (i in A1) then writeln (i,' is in A1') else writeln (i,' is not in A1'); End;
  • 22.
    True statement A0,A1 : Set of 1..15; A : boolean; A0 := [1, 2]; A1 := [2, 4]; A0 := A0 – [77]; A := A1 >= A0; A := 1 in A0;
  • 23.
    Const Sets Type Digits = set of 0..9; Const HexD : set of '0'..'z‘ = ['0'..'9', 'A'..'F', 'a'..'f']; ED : Digits = [0, 2, 4, 6, 8]; Var d : Digits; Begin d := [8]; d := ED; {d=[0,2,4,6,8]} ED:=ED+[9]; ED:=d; End. +1 Error .. Fateh 3eoonk !!
  • 24.
    Enum Set Type Day = (sun,mon,….,sat); Name=(koko,soso,fofo,fifi); Var days: Set of Day; N:set of Name Begin Days:=[sun..sat]; N:=[KOKO,SOSO]; End.
  • 25.
  • 26.
    Program Test(); TypeSInt = Set of 1..150 ; SCh = Set of ‘0’..’z’; Var S1 : SInt; S2 : SCh; Slen : Integer; Begin Readln(Slen); ReadsetI(S1 , Slen); ReadsetC(S2 , Slen); PrintsetI(S1 , Slen); PrintsetC(S2 , Slen); Readln; End.
  • 27.
    Read Integer Sets Procedure ReadsetI (var S:SInt; L:integer) ; var i, x : integer; Begin s:=[]; For i:=1 to L do begin Read(x); S := S + [x]; end; End;
  • 28.
    Read Char Sets Procedure ReadsetC (var S:SCh; L:integer) ; var i, x : Char; Begin s:=[]; For i:=1 to L do begin Read(x); S := S + [x]; end; End;
  • 29.
    Print Integer SetsUsing While Loop: Procedure PrintsetI (S : SInt) ; var I : Integer; Begin I := 0; While ( S <> []) do If (I in S) then begin Writeln(I); S := S – [I]; end; I := I + 1; End;
  • 30.
    Print Integer SetsUsing For Loop Procedure PrintsetI (S : SI) ; var I : Integer; Begin For I:=1 to 32700 do Begin If (I in S) then Begin Writeln(I); S := S – [I]; End; If (S = []) then I := 32700; End; End;
  • 31.
    Exercise : يرىفي يؼهذ يا إػطاء دوراخ في يادذي انرياضياخ وانهغح الإ كَهيسيح يؼطى كم طانة ػ ذُ ذسجيهه في ان ؼًهذ رقى فريذ يحصىر تي 1..100 فإرا ػه دً أ ػذد انطلاب في كم يادج لا يرجاوز 50 طانة ان طًهىب كراتح تر اَيج ػاو تاسرخذاو الاجرائياخ وان جً ىًػاخ ورنك نهقياو تان هًاو انرانيح : . 1 ذشكيم يج ىًػح نطلاب انرياضياخ ويج ىًػح نطلاب انهغح الإ كَهيسيح )إدخال ػ اُصر ان جً ىًػح ( . 2 إجراء نطثاػح ػ اُصر ان جً ىًػح . 3 إجراء لإػطاء يج ىًػح تأرقاو انطلاب ان سًجهي تان اًدذي . 4 قررخ إدارج ان ؼًهذ ذخفيض ػذد انطلاب ورنك تالاسرغ اُء ػ ػذد يحذد ي هُى يذخم ي نىحح ان فًاذيح ػهى أ يرى اخريار أرقاو انطلاب ان فًصىني تشكم ػشىائي وان طًهىب كراتح إجراء ن قُم أرقاو انطلاب ان فًصىني إنى يج ىًػح جذيذج . 5 وضغ أرقاو انطلاب ان فًصىني ض شؼاع
  • 32.
    Program prog2byte_team; Useswincrt; Type students=set of 1..100; numbers=array[1..50] of 1..100; Var seng,smath : students; Procedure inputset(var s : students; m:integer); Var i,x: integer; Begin s:=[ ]; i:=0; While (i<m) do begin writeln(„input students number „); readln(x); if (x in s) then writeln(„ you input this number befor please enter another number „) else begin i:=i+1; s:=s+[x]; end; end; End; numbers of students
  • 33.
    Procedure printset(s :students); Var i:integer; Begin i:=1; While (s<>[ ]) do begin if (i in s) then begin write(i:5); s:=s-[ i ]; end; i:=i+1; end; writeln; End;
  • 34.
    Procedure bothsub(s1,s2 :students; var s3: students); Begin s3:=s1*s2; End;
  • 35.
    Procedure deletestd(var s,n: students); Var k,i,x ; integer; Begin n:= [ ]; Randomize; i:=0; Writeln(„enter the number you want to go throw out „); Readln(x); While (i<x) do begin k:= random(100) + 1; if ( k in s ) then begin s:=s – [ k ]; seng:= seng – [ k ]; smath:=smath – [ k ]; i:=i+1; n:=n + [ k ]; end; end; End; بلاطنا حػىًجي ان فًصىني يج ىًػح انرقاطغ :Randomize يقىو ترىنيذ أرقاو ػشىائيح أػر اًدا ػهى ساػح ان ظُاو :Random(100)=0..99; Random(100)+1=1..100
  • 36.
    Procedure setinArray(s: students;var a: numbers ; var k: integer); Var i : integer; Begin K:=0; For i:=1 to 100 do If (i in s) then begin k:=k+1; a[k]:=i; end; End; ي أجم اسرذػاء انشؼاع في انثر اَيج انرئيسي
  • 37.
    Var nmath,neng,k,i :integer; Aunaccepted : numbers; Sunaccepted,sboth : students; Begin Writeln(„enter the number of math students „); Readln(nmath); Inputset(smath,nmath); Writeln(„enter the number of English students „); Readln(neng); Inputset(seng,neng); Bothsub(smath , seng , sboth); Printset(sboth); Deletestd(sboth,Sunaccepted); Printset(Sunaccepted); setinArray(Sunaccepted,Aunaccepted,k); For i:=1 to k do Writeln(Aunaccepted[i]:5); Readln; End.
  • 38.
    Homework: Creat andread two arrays of student numbers, student numbers in Prog and in English. -We want to know the students numbers at the two subjects..?! -what are the student numbers at the Prog and Not at English ?? +10 point
  • 39.
    Group : grouplink Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 2 bytes team
  • 40.
  • 41.
    Ques: write aprogramme DO: 1-Read An Array 2-Print An Array//Proce 3-function to find the min elem in the array 4-Procedure to find the Sum array(of the tow arrays). 5- Multi array Write the Main Program..
  • 42.
    Programme P-Matrix; ConstnMax=20; mMax=20; Type Matrix=array[1..nmax,1..mmax] of real; Var A,B,Add,mult :Matrix; n1,n2 :1..nmax; m1,m2 :1..mmax; min: integer;
  • 43.
    Procedure ReadMat(Var: n:1..nmax;varm:1..mmax; var A:matrix); Var i,j:integer; begin writeln(„enter the first Dimention of matrix< ‟ ,nmax); Readln(n); writeln(„enter the second Dimention of matrix< ‟ ,mmax); Readln(m); for i:=1 to n do begin for j:=1 to m do read(A[I,j]); {hint} readln; {hint} end; end;
  • 44.
    Procedure WriteMat(Var: n:1..nmax;varm:1..mmax; var A:matrix); Var i,j:integer; begin for i:=1 to n do begin for j:=1 to m do write(A[i,j],‟ ‟); writeln; end; end;
  • 45.
    Function MinOfMatrix(n:1..nmax,m:1..mmax;A:matrix):real Vari,j:integer; min:real; begin min:=A[1,1]; For i:=1 to n do for j:=1 to m do if (A[i,j]<min) then min:=A[i,j]; MinOfMatrix:=min; end;
  • 46.
    Procedure Add_Tow_Matrix(n1,n2:1..nmax; m1,m2:1..mmax;var n3:1..nmax; var m3:1..mmax; var c:Matrix); Var i,j:integer; begin if(n1<>n2)or(m1<>m2) then writeln(„the addition is impossible‟); else begin n3:=n1; m3:=m1; for i:=1 to n3 do for j:=1 to m3 do C[i.j]:=A[i,j]+B[i,j]; end; end;
  • 47.
    Procedure Mult_Tow_Matrix(n1,n2:1..nmax; m1,m2:1..mmax;var n3:1..nmax; var m3:1..mmax; var c:Matrix); Var i,j,k:integer; begin if(n1<>m2) then writeln(„the multi is impossible‟); else begin n3:=n2; m3:=m1; { A(m1,n1)*B(m2,n2)=C(m3,n3)} for i:=1 to n3 do for j:=1 to m3 do begin C[i,j]=0; for k:=1 to m2 C[i.j]:= C[i.j] +A[i,k]*B[k,j]; end; end; end;
  • 48.
    Begin ReadMat(n1,m1,A); WriteMat(n1,m1,A); ReadMat(n2,m2,B); WriteMat(n2,m2,B); writeln(„the minimum of the first Mat = ‟); min:=MinOfMatrix(n1,m1,A); writeln(min); Add_Tow_Matrix(n1.m1,n2,m2,A,B,n3,m3,Add); WriteMat(n3,m3,Add); Mult_Tow_Matrix(n1,n2,m1,m2,A,B, n3,m3,mult); WriteMat(n3,m3,mult); End;
  • 49.
    Group : grouplink Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 2 bytes team