قالب وبلاگ قالب وبلاگ
دانشگاه پیام نور بندرعباس

دانشگاه پیام نور بندرعباس
 
دانشجویان پیام نور بندرعباس

محل درج آگهی و تبلیغات
 
نوشته شده در تاريخ سه شنبه بیست و دوم اردیبهشت 1388 توسط امین علیمرادی

program Four_Action;
uses wincrt;
var
a,b,c,y,HAM:array[1..50,1..50] of integer;
x:array [1..50] of integer;
w:array[1..3,1..3] of real;
t:array[1..10,1..10] of real;
k,x_t:array[1..9] of real;
i,j,n,m,o,p,z,sum,ib,s,ix,iy,jy,f,h,min_i,max_i,min_j,max_j,r,det,d,ik,q,fi:integer;
one,z_t,sum_t:real;
op:char;
flag:boolean;
begin
writeln('In the name of GUD':50); {in the name Of GOD}
writeln;
writeln(' this program can do "Multiplication" , "Division" , "Addition" and');
writeln(' "Subtract" on the Matrixes');
writeln;
writeln(' I to hope you content from this program');     {OMIDVARAM...}
writeln;
writeln;
writeln('Compiler: Amin Alimoradi');  {AMIN ALIMORADI}
writeln;
writeln('Number of Scholar: 871248618 ');
writeln;
writeln('Name of Master :Mr Moslempoor');
writeln('---------------------------------------------------------------');
writeln;
write('Press Enter to continue... ':50);     {Press Enter}
readln;
writeln('________________________________________________________________________________');

for s:=1 to 100 do
begin
m:=0; n:=0; o:=0; p:=0; flag:=false; i:=1; j:=1; ib:=1;  ix:=1;
iy:=1; min_i:=1; max_i:=1; min_j:=1; max_j:=1; ik:=1; q:=0; z:=0;
f:=0; h:=0; r:=0; det:=0; d:=0; fi:=0;
one:=0; z_t:=0; sum_t:=0;
write('Please Enter Your ROW''s of first Matrix : ':60);
readln(n);
write('Now Enter Number of COLUMN''s: ':60);
readln(m);
writeln;
write('Your Matrix is a Matrix of ',n,'x',m,' . Please Enter every ',n*m,' numbers of this Matris : ');
writeln;
writeln('(By ''Enter key'' or ''Space key'')':50);

for i:=1 to n do
for j:=1 to m do
read(a[i,j]);
readln;
writeln;
writeln('Your Matris is:':5);{your matris}
for i:=1 to n do
begin
for j:=1 to m do
if j=1 then
begin
write('':20);
write(a[i,j]:5);
end{end of if}
else
write(a[i,j]:5);
writeln;
end;{end of for}
writeln;
write('Please Enter a operetor (''+'' or ''*'' or ''/'' or ''-''): ');

readln(op);
while (op<>('/')) and (op<>('*')) and (op<>('+')) and (op<>('-')) do
begin
fi:=fi+1;
if fi=1 then
begin
writeln;
writeln('Error..! Please Just Enter (''+'' or ''*'' or ''/'' or ''-'')');
 writeln(' This Key are in Right of Keyboard.');
 writeln;
 write(' Enter again Operator:'); {Enter again}
 end;

readln(op);
if (op<>('/')) and (op<>('*')) and (op<>('+')) and(op<>('-')) then
begin
 writeln;
 writeln('Error..! Please Just Enter (''+'' or ''*'' or ''/'' or ''-'')');
 writeln(' This Key are in Right of Keyboard.');
 writeln;
 write(' Enter again Operator:'); {Enter again}
flag:=true;
end
else
 if ((flag=true) or (fi=1)) then
 begin
writeln('OKAY':30);
writeln
end;
end;

case op of
'*': begin
writeln;
write('to Multiplication Begining Enter ROW''s of Secound Matrix : '); {Enter Second Matrix}

while o<>m do
begin
readln(o);
if o<>m then
begin
writeln;
writeln('Error..! Two Matrix Can''nt Be Multiplication Because ROW''s of Secound Matris ');{cannt be ZARB}
writeln('arenot Equal to COLUMN''s of First Matrix.');
writeln;
writeln('Please Enter again:'); {Enter again}
flag:=true;
end
else
if flag=true then
begin
writeln('Okay');
writeln;
end;
end;

if (m=o) then
begin
write('PLease Enter Number of Column''s :':3);
readln(p);
writeln;
write('Your Matrix is a Matrix of ',o,'x',p,' . Please Enter every ',o*p,' numbers of this Matris :  ');
writeln;
writeln('(By ''Enter key'' or ''Space key'')':50);
for i:=1 to o do
for j:=1 to p do
read(b[i,j]);
writeln;
writeln('your Matrix is:':3);{your matris}
for i:=1 to o do
begin
for j:=1 to p do
if j=1 then
begin
write('':20);
write(b[i,j]:5);
end{end of if}
else
write(b[i,j]:5);
writeln;
end;{end of for}
writeln;
writeln('also Multiplication of two matris is:':3); {ZARB of two matris}
writeln;


begin
ix:=1;
  for i:=1 to n do
  for ib:=1 to p do
  begin
    sum:=0;
    for j:=1 to m do
    begin
      z:= a[i,j]*b[j,ib];
      sum:= sum+z;
    end;
    x[ix]:=sum;
    ix:= ix+1;
  end;

  ix:=1;
  for iy:=1 to n do
  for jy:=1 to p do
  begin
  y[iy,jy]:=x[ix];
  ix:=ix+1;
  end;
  for iy:=1 to n do
  begin
  for jy:=1 to p do
  if jy=1 then
  begin
  write('':20);
  write(y[iy,jy]:5);
  end
  else
  write(y[iy,jy]:5);
  writeln;
  end;
  end;
  end;
  (*else
  begin
  writeln;
  write('.I?C! E?ICI ?E?? ?C? ?CE??? C?? EC?I EC E?ICI ????C? ?CE??? I?? E?CE? ECOI');{cannt be ZARB}
  writeln;
  end;*)
  writeln;
  write('Press Enter To ReStart...':53);{press ENter to continue}
  readln;
  readln;
  writeln('______________________________________________________________________________');
  end;{end of ZARB(*)}


  '+': begin
  write('to Addition Begining Enter ROW''s of Secound Matrix : ');

while o<>n do
begin
readln(o);
if o<>n then
begin
writeln;
writeln('Error..! RoW''s of first matris isnot Equal to ROW''s of Secound Matris. ');{first satr & secound satr}
writeln;
writeln('Please Enter again :':3); {Enter again}
flag:=true
end
else
if flag=true then
writeln('Okay':30); {OK}
end;
if (n=o) then
begin

write('PLease Enter Number of Column''s :':3); {Enter Soton}
while p<>m do
begin
readln(p);
if p<>m then
begin
writeln;
writeln('Error..! Column''s of first matris isnot Equal to Column''s of Secound Matris. ');{cannt be ZARB}
writeln;
writeln('Please Enter again;':3); {Enter again}
flag:=true
end
else
if flag=true then
writeln('Okay':30); {OK}
end;
if (m=p) then
begin
writeln;
write('Your Matrix is a Matrix of ',o,'x',p,' . Please Enter every ',o*p,' numbers of this Matris :  ');
writeln;
writeln('(By ''Enter key'' or ''Space key'')':50);
for i:=1 to o do
for j:=1 to p do
read(b[i,j]);
writeln;
writeln('your Matrix is:':3); {your matris: }
for i:=1 to o do
begin
for j:=1 to p do
if j=1 then
begin
write('':20);
write(b[i,j]:5);
end{end of if}
else
write(b[i,j]:5);
writeln;
end;{end of for}
writeln;
end
else
writeln('Error..! two matris cann''t be GAM''A because not(':50,m,'=',p,')');
end
else
writeln('Error..! Two Matris cann''t be Gam''A because not(':50,n,'=',o,')');

for i:= 1 to n do
for j:=1 to  m do
c[i,j]:=a[i,j]+b[i,j];


writeln('And yuor Aadition is:':3); {your matris: }
for i:=1 to o do
begin
for j:=1 to p do
if j=1 then
begin
write('':20);
write(c[i,j]:5);
end{end of if}
else
write(c[i,j]:5);
writeln;
end;{end of for}
writeln;

   write('Press Enter to ReStart...':50);{press ENter to continue}
  readln;
  readln;
  writeln('______________________________________________________________________________');
  end;{end of '+'}

{______________________________________________________________________________________________}

'/':
 begin
 writeln;
writeln('to Division Secound Matrix must be a Square Matrix means (nxn)');
write( 'Please Enter number of n :'); { Enter nxn }

while ((q<>m) and (q<>1)) do
begin
readln(q);
if ((q<>m) and (q<>1)) then
begin
writeln;
writeln('Error..! RoW''s of Secound matris isnot Equal to Column''s of First Matris. ');{cannt be ZARB}
writeln;
writeln('Please Enter again':3); {Enter again}
flag:=true;
end
else
if ((q<=3)and (flag=true)) then
writeln('Okay':30);
end;
if (q=3) and (q=m) then
begin
writeln;
write('Your Matrix is a Matrix of 3x3 . Please Enter every 9 numbers of this Matris : ');
writeln;
writeln('(By ''Enter key'' or ''Space key'')':50);
for i:= 1 to 3 do
for j:= 1 to 3 do
read(b[i,j]);
readln;

writeln('your Matrix is:':3);{your matris}
for i:=1 to 3 do
begin
for j:=1 to 3 do
write(b[i,j]:5);
writeln;
end;
writeln;


{------------------------------------------------------------------}

ix:=1;

for i:=1 to 3 do
begin
for j:=1 to 3 do
begin


case i of
1:begin
min_i:=2;
max_i:=3;
end;

2:begin
min_i:=1;
max_i:=3;
end;

3:begin
min_i:=1;
max_i:=2;
end;
end;


case j of
1:begin
min_j:=2;
max_j:=3;
end;

2:begin
min_j:=1;
max_j:=3;
end;

3:begin
min_j:=1;
max_j:=2;
end;
end;

if((i+j) mod 2)=0 then
r:= (b[min_i , min_j]* b[max_i, max_j])-(b[min_i, max_j]* b[max_i,min_j])
else
r:= -1*((b[min_i , min_j]* b[max_i, max_j])-(b[min_i, max_j]* b[max_i,min_j]));
x[ix]:=r;
ix:=ix+1;
end;
end;

{writeln('HAMSAZEH:');}
ix:=1;
for i:=1 to 3 do
for j:=1 to 3 do
begin
HAM[j,i]:=x[ix];
ix:=ix+1;
end;
writeln;

{for i:=1 to 3 do
begin
for j:=1 to 3 do
write(HAM[i,j]:5);
writeln;
end;}

d:=(b[1,1]*((b[2,2]*b[3,3])-(b[2,3]*b[3,2])))-(b[1,2]*((b[2,1]*b[3,3])-(b[2,3])*b[3,1]));
det:=d+(b[1,3]*((b[2,1]*b[3,2])-(b[2,2]*b[3,1])));
if det=0 then
writeln('Error..! this Division is No Compliment! Because Determinan of secound Matris is Zero.' ){ Determinan Taarif Nashode }
else
begin

for i:=1 to 9 do
k[i]:=(1/det)*(x[i]);

for i:=1 to 9 do
k[i]:= x[i]*(1/det);


ik:=1;
for i:=1 to 3 do
for j:=1 to 3 do
begin
w[i,j]:=k[ik];
ik:=ik+1;
end;
writeln;

{writeln('WAROON of your Matris:');}
writeln;

{for i:=1 to 3 do
begin
for j:=1 to 3 do
write(w[j,i]:2,'':5);
writeln;
writeln;
writeln;
end;}
end;
end;

{------------------------------------------------------ (q=2)    }
if ((q=2) and (q=m)) then
begin
writeln;
 writeln('Secound Matrix is 2x2 please Enter every 4 number from your Matrix :');
 writeln;
writeln('(by ''Enter key'' or ''Space key'')':50);
for i:=1 to 2 do
for j:=1 to 2 do
read(b[i,j]);
readln;

writeln('your Martix is:':3);{your matris}
for i:=1 to 2 do
begin
for j:=1 to 2 do
if j=1 then
begin
write('':20);
write(b[i,j]:5);
end
else
write(b[i,j]:5);
writeln;
end;

det:= (b[1,1]*b[2,2])-(b[1,2]*b[2,1]);
if det=0 then
writeln('Error..! this Division is No Compliment! Because Determinan of secound Matris is Zero.'){ Determinan Taarif Nashode }
else
begin

w[1,1]:=(1/det)*b[2,2];
w[1,2]:=(1/det)*b[1,2]*(-1);
w[2,1]:=(1/det)*(b[2,1])*(-1);
w[2,2]:=(1/det)*(b[1,1]);
writeln;
{writeln('WAROON:');
for i:=1 to 2 do
begin
for j:=1 to 2 do
write(w[i,j],'':5);
writeln;
end;}
end;
end;

{----------------------------------------------------- (q=1)     }

if (q=1) then
begin
writeln;
writeln('your Matrix Will be a Scaler. please Enter your scaler.');
write('(your scaler can be a Fract number.) : ':50);   {Enter  Scaler        }

 

readln(one);
writeln;
if one=0 then
writeln('Error..! the Division is No comliment. Because your number is Zero.' )        { TAARIF NASHODE }
else
writeln('Division of Matrix on the Number:');
writeln;
begin
for i:=1 to n do
for j:=1 to m do
t[i,j]:= (a[i,j]*(1/(one)));

for i:=1 to n do
begin
for j:=1 to m do
write(t[i,j]:2,'':5);
writeln;
end;
end;
end;


if not((q=m)or(q=1)) then
writeln('I?C!I? ?CE??? U?? ?CE? E?????I ???C ?E?? ?CE??? C?? EC ??? ?CE??? I?? ?CE?CE?C?E')  { No TAGHSIM}
else
if ((q<>3) and (q<>2)and(q<>1)) then
begin
writeln;
writeln('Sorry! This program to Division just Compliment to Matris of 3x3 or lower');


end;

 

{_____________________________________________________(BEGIN OF ZARB) _______________________________________________________}

if (det<>0) then

if (q=3) or (q=2) then
begin
begin

ix:=1;
  for i:=1 to n do
  for ib:=1 to m do
  begin
    sum_t:=0;
    for j:=1 to m do
    begin
      z_t:= a[i,j]*w[ib,j];
      sum_t:= sum_t + z_t;
    end;
    x_t[ix]:=sum_t;
    ix:= ix+1;
  end;
 

  ix:=1;
  for iy:=1 to n do
  for jy:=1 to m do
  begin
  t[iy,jy]:=x_t[ix];
  ix:=ix+1;
  end;

  writeln('Division Of two Matrix:':3);
  writeln;
  for iy:=1 to n do
  begin
  for jy:=1 to m do
  if jy=1 then
  begin
  write('':17);
  write(t[iy,jy],'':5);
  end
  else
  write(t[iy,jy],'':5);
  writeln;
  end;
  end;
  end
  else
  begin
  writeln;
  write('                ERROR..! Two Matris Cann''t be ZARB together because Not(',m,'=',o,')');
  writeln;
  end;{end of else}
  writeln;
  write('Press Enter to ReStart... ':50);{press ENter to continue}
  readln;
  writeln('______________________________________________________________________________');

end;{end of '/'}
{_________________________________________________________________________________________________________________________}

 '-':begin
  write('to Subtract Begining Enter ROW''s of Secound Matrix : ');

while o<>n do
begin
readln(o);
if o<>n then
begin
writeln;
writeln('Error..! RoW''s of first matris isnot Equal to ROW''s of Secound Matris. ');{first satr & secound satr}
writeln('Please Enter again :':3); {Enter again}
flag:=true
end
else
if flag=true then
writeln('Okay':30); {OK}
end;
if (n=o) then
begin

write('PLease Enter Number of Column''s :':3); {Enter Soton}
while p<>m do
begin
readln(p);
if p<>m then
begin
writeln;
writeln('Error..! Column''s of first matris isnot Equal to Column''s of Secound Matris. ');{cannt be ZARB}
writeln;
writeln('Please Enter again;':3); {Enter again}
flag:=true
end
else
if flag=true then
writeln('Okay':30); {OK}
end;
if (m=p) then
begin
writeln;
write('Your Matrix is a Matrix of ',o,'x',p,' . Please Enter every ',o*p,' numbers of this Matris :  ');
writeln;
writeln('(By ''Enter key'' or ''Space key'')':50);
for i:=1 to o do
for j:=1 to p do
read(b[i,j]);
writeln;
writeln('your Matrix is:':3); {your matris: }
for i:=1 to o do
begin
for j:=1 to p do
if j=1 then
begin
write('':20);
write(b[i,j]:5);
end{end of if}
else
write(b[i,j]:5);
writeln;
end;{end of for}
writeln;
end
else
writeln('Error..! two matris cann''t be GAM''A because not(':50,m,'=',p,')');
end
else
writeln('Error..! Two Matris cann''t be Gam''A because not(':50,n,'=',o,')');

for i:= 1 to n do
for j:=1 to  m do
c[i,j]:=a[i,j]-b[i,j];


writeln('Subtract of two matrix is:':3); {your matris: }
for i:=1 to o do
begin
for j:=1 to p do
if j=1 then
begin
write('':20);
write(c[i,j]:5);
end{end of if}
else
write(c[i,j]:5);
writeln;
end;{end of for}
writeln;

   write('Press Enter to ReStart...':50);{press ENter to continue}
  readln;
  readln;
  writeln('______________________________________________________________________________');
  end;{end of '-'}
 

  end;{end of case}
    end;{end of for}
  end.{end of program}


.: Weblog Themes By Pichak :.


تمامی حقوق این وبلاگ محفوظ است | طراحی : پیچک
قالب وبلاگقالب وبلاگ