0% found this document useful (0 votes)
41 views11 pages

Program Produsul - A - Doua - Matrice

The document contains several Pascal programs related to data analysis and statistics. The programs calculate things like: - Matrix multiplication - Prime factor decomposition - Sorting arrays - Averages and totals across categories - Minimum and maximum values - Forest structure analysis based on age classes and consistency categories

Uploaded by

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

Program Produsul - A - Doua - Matrice

The document contains several Pascal programs related to data analysis and statistics. The programs calculate things like: - Matrix multiplication - Prime factor decomposition - Sorting arrays - Averages and totals across categories - Minimum and maximum values - Forest structure analysis based on age classes and consistency categories

Uploaded by

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

Program produsul_a_doua_matrice;

type
matrice=array[1..30,1..30] of real;
var
i,j,k,m,n,p: integer;
a,b,c: matrice;
begin
write ('Numarul de linii al matricei A='); readln (m);
write ('Numarul de coloane al matricei B='); readln (n);
write ('Numarul de linii al matricei B si de coloane pentru A='); readln (p);
writeln ('Precizati elementele matricei A:');
for i:=1 to m do
for k:=1 to p do
begin
write ('a(',i,',',k,')=');
readln (a[i,k]);
end;
writeln ('Precizati elementele matricei B:');
for k:=1 to p do
for j:=1 to n do
begin
write ('b(',k,',',j,')=');
readln (b[k,j]);
end;
for i:=1 to m do
for j:=1 to n do
begin
c[i,j]:=0;
for k:=1 to p do
c[i,j]:=c[i,j]+a[i,k]*b[k,j];
end;
writeln ('Matricea C:');
for i:=1 to m do
begin
for j:=1 to n do
write (' c(',i,',',j,')=',c[i,j]:6:2);
writeln;
end;
end.

Program descompunere_n_factori_primi;
uses CRT;
type
vector = array[1..50] of integer;
var
factori,exponenti: vector;
m: longint;
n,i,r,c: integer;
cont: char;
begin
repeat
repeat
write('Introdu M=');
read(m);
until (m<>0) and (m<>1);
if m<0
then
m:=-m;
n:=0;
i:=1;

repeat
repeat
i:=i+1;
r:=m mod i;
until r=0;
n:=n+1;
factori[n]:=i;
exponenti[n]:=0;
repeat
exponenti[n]:=exponenti[n]+1;
m:=m div i;
r:=m mod i;
until (r<>0) or (m=1);
until m=1;
i:=0;
repeat
i:=i+1;
writeln('F(',i,')=',factori[i],' E(',i,')=',exponenti[i]);
until i=n;
write ('Continuati(da=1/nu=0):');
cont:=readkey;
until cont='0';
end.

Program ordonare;
uses CRT;
type
vector= array[1..50] of real;
vectory=array[1..50] of integer;
var
n,i,j,comu,nv,yaux: integer;
xaux: real;
x,z: vector;
y: vectory;
begin
repeat
write (Introduceti N=);
read (n);
until n>1;
writeln (Introduceti sirul X);
for i:=1 to n do
begin
write (x(,i,)=);
read (x[i]);
end;
for i:=1 to n do
begin
z[i]:=x[i];
y[i]:=i;
end;
nv:=n-1;
repeat
comu:=0;
for i:=1 to nv do
begin
j:=i+1;
if x[i] > x[j]
then
begin
xaux:=x[i];

yaux:=y[i];
x[i]:=x[j];
y[i]:=y[j];
x[j]:=xaux;
y[j]:=yaux;
comu:=1;
end;
end;
until comu=0;
writeln (Sirul initial);
for i:=1 to n do
write (z(,i,)=,z[i]: 6: 2,; );
writeln( );
writeln (Sirul ordonat);
for i:=1 to n do
write (x(,i,/,y[i],)=,x[i]: 6: 2,; )
end.

Program var_as_coef_de_var;
type
date=array[byte] of integer;
var
x,n:date;
i,nc,sn,snx:integer;
xm,svar,va,as,cv,cvl:real;
begin
write('Numarul de categorii =');
readln(nc);
sn:=0;snx:=0;
for i:=1 to nc do
begin
write('Categoria ',i,' :');
write(' X =');read(x[i]);
write('
N =');readln(n[i]);
sn:=sn+n[i];
snx:=snx+n[i]*x[i];
end;
write('Precizati coef.de variatie limita =');readln(cvl);
xm:=snx/sn;
svar:=0;
for i:= 1 to nc do
svar:=svar+n[i]*sqr(x[i]-xm);
va:=svar/(sn-1);
as:=sqrt(va);
cv:=as/xm;
writeln('Varianta =',va:9:6);
writeln('Abaterea standard =',as:9:6);
writeln('Coef.de variatie =',cv:6:4);
if cv<=cvl then writeln('Colectivitate omogena')
else writeln('Colectivitate neomogena');
end.
Program indice_de_asimetrie;
const
nc=15; { nc=numar de categorii}
type
date=array[1..nc] of integer;
const
n:date=(7,10,12,22,29,36,48,53,41,32,28,19,13,7,2);

var x:date;
i,sn,snx:integer;
iasm,sasm,as,xm,sa:real;
begin
write('Categoria initiala =');readln(x[1]);
write('Abaterea standard =');readln(as);
for i:=2 to nc do
x[i]:=x[i-1]+2;
sn:=0;snx:=0;
for i:=1 to nc do
begin
sn:=sn+n[i];
snx:=snx+n[i]*x[i];
end;
xm:=snx/sn;
sa:=0;
for i:=1 to nc do
sa:=sa+n[i]*sqr(x[i]-xm)*(x[i]-xm);
iasm:=sa/(sn*exp(3*ln(as)));
sasm:=sqrt(6/(sn+3));
writeln('Indicele de asimetrie =',iasm:8:5,' cu eroarea ',sasm:4:2);
if iasm<=0 then write('Asimetrie de dreapta, ')
else write('Asimetrie de stinga, ');
if abs(iasm)/sasm<=2 then writeln('nesemnificativa')
else writeln('semnificativa');
end.

Program indice_de_exces;
const
nc=15; { nc=numar de categorii}
type
date=array[1..nc] of integer;
const
n:date=(7,10,12,22,29,36,48,53,41,32,28,19,13,7,2);
var x:date;
i,sn,snx:integer;
iexc,sexc,as,xm,sa:real;
begin
write('Categoria initiala =');readln(x[1]);
write('Abaterea standard =');readln(as);
for i:=2 to nc do
x[i]:=x[i-1]+2;
sn:=0;snx:=0;
for i:=1 to nc do
begin
sn:=sn+n[i];
snx:=snx+n[i]*x[i];
end;
xm:=snx/sn;
sa:=0;
for i:=1 to nc do
sa:=sa+n[i]*sqr(x[i]-xm)*sqr(x[i]-xm);
iexc:=sa/(sn*exp(4*ln(as)))-3;
sexc:=sqrt(6/(sn+3));
writeln('Indicele de exces =',iexc:8:5,' cu eroarea ',sexc:4:2);
if iexc<=0 then write('Varful curbei experimentale este situat sub varful curbei normale, ')
else write('Varful curbei experimentale este situat deasupra curbei normale,');
if abs(iexc)/sexc<=2 then writeln('exces nesemnificativ')
else writeln('exces semnificativ');
end.

Program temperaturi_medii_pe_decade_si_pentade;
const
n=31;
type
temp=array[1..n] of real;
dec=array[1..3] of real;
pent=array[1..6] of real;
const
t:temp=(-5.5,-4.9,-5.6,-5.8,-5.0,-3.0,-2.4,-0.5,-1.7,-0.1,
1.2,1.3,1.5,3.1,3.2,3.2,5.1,6.2,6.9,7.8,
9.5,8.8,7.7,5.5,6.4,5.2,3.3,2.1,5.5,6.6,8.4);
var
i,k:byte;
td:dec;
tp:pent;
tm:real;
begin
for i:=1 to 3 do
td[i]:=0;
for i:=1 to 6 do
tp[i]:=0;
for i:=1 to 20 do
begin
k:=trunc((i-1)/10+1);
td[k]:=td[k]+t[i];
end;
for i:=21 to n do
td[3]:=td[3]+t[i];
for i:=1 to 25 do
begin
k:=trunc((i-1)/5+1);
tp[k]:=tp[k]+t[i];
end;
for i:=26 to n do
tp[6]:=tp[6]+t[i];
tm:=(td[1]+td[2]+td[3])/n;
{temperatura medie a lunii}
for i:=1 to 2 do
td[i]:=td[i]/10;
td[3]:=td[3]/(n-20);
for i:=1 to 5 do
tp[i]:=tp[i]/5;
tp[6]:=tp[6]/(n-25);
writeln('Temperaturi medii pe decade:');
for i:=1 to 3 do
writeln('decada ',i,'=',td[i]:5:2);
writeln('Temperaturi medii pe pentade:');
for i:=1 to 6 do
writeln('pentada ',i,'=',tp[i]:5:2);
writeln('Temperatura medie a lunii =',tm:5:2);
end.
Program temp_minima_si_maxima;
const
n=30;
type
temp=array[1..n] of real;
const

t:temp=(-5.5,-4.9,-5.6,-5.8,-5.0,-3.0,-2.4,-0.5,-1.7,-0.1,
1.2,1.3,1.5,3.1,3.2,3.3,5.1,6.2,6.9,7.8,
9.5,8.8,7.7,5.6,6.4,5.2,3.3,2.1,5.5,6.6);
var
i,imax,imin:byte;
tmin,tmax:real;
begin
tmin:=t[1];
tmax:=t[1];
for i:=1 to n do
if tmin>t[i] then
begin
tmin:=t[i];
imin:=i;
end;
for i:=1 to n do
if tmax<t[i] then
begin
tmax:=t[i];imax:=i;
end;
writeln('temperatura minima =' ,tmin:5:1, ' in ziua ' ,imin);
writeln('temperatura maxima =' ,tmax:5:1, ' in ziua ',imax);
end.
Program structura_fondului_forestier_pe_clase_de_varsta;
type tip1=array[byte] of real;
tip2=array[byte] of integer;
tip3=array[1..5] of real;
var n,i
:byte;
s,c
:tip1;
vr
:tip2;
sc,sr,cm :tip3;
begin
write('Numar de arborete=');readln(n);
for i:=1 to 5 do
begin
sc[i]:=0;
sr[i]:=0;
end;
writeln('Precizati caracteristicile fiecarui arboret');
for i:=1 to n do
begin
writeln('Arboretul ',i);
write('Suprafata=');read(s[i]);
write('Virsta=');read(vr[i]);
write('Consistenta=');read(c[i]);
case vr[i] of
1..20:begin
sc[1]:=sc[1]+s[i];
sr[1]:=sr[1]+s[i]*c[i];
end;
21..40:begin
sc[2]:=sc[2]+s[i];
sr[2]:=sr[2]+s[i]*c[i];
end;
41..60:begin
sc[3]:=sc[3]+s[i];
sr[3]:=sr[3]+s[i]*c[i];
end;
61..80:begin
sc[4]:=sc[4]+s[i];

sr[4]:=sr[4]+s[i]*c[i];
end;
else begin
sc[5]:=sc[5]+s[i];
sr[5]:=sr[5]+s[i]*c[i];
end;
end;
end;
for i:=1 to 5 do
begin
write('Clasa ',i,' de virsta:');
if sc[i]=0 then writeln(' nu sint arborete')
else begin
cm[i]:=sr[i]/sc[i];
writeln(' Suprafata=',sc[i]:10:1,' ha Supr.redusa=',
sr[i]:10:1,' ha
Consist.medie=',cm[i]:3:1);
end;
end;
end.

Program structura_fond_forestier_volume_pe_clase_de_varsta;
type tip1=array[byte] of real;
tip2=array[byte] of longint;
var n,i,k,max:byte;
v,vr,vol:tip2;
s,supr,vh:tip1;
begin
write('Nr.de arborete=');readln(n);
writeln('Precizati caracteristicile fiecarui arboret');
max:=1;
for i:=1 to n do
begin
writeln('Arboretul ',i);
write('Suprafata=');read(s[i]);
write('Virsta=');read(vr[i]);
write('Volumul=');readln(v[i]);
k:=trunc((vr[i]-1)/20)+1;
if max<k then max:=k;
end;
for i:=1 to max do
begin
supr[i]:=0;vol[i]:=0;
end;
for i:=1 to n do
begin
k:=trunc((vr[i]-1)/20)+1;
supr[k]:=supr[k]+s[i];
vol[k]:=vol[k]+v[i];
vh[k]:=vol[k]/supr[k];
end;
for i:=1 to max do
begin
write('Clasa ',i,' de virsta:');
if supr[i]=0 then writeln(' nu sint arborete')
else writeln('Volum total=',vol[i],' m3; volum/ha=',vh[i]:1:2,
' m3/ha');
end;
end.

Program structura_pe_categorii_de_consistenta;
type tip1=array[byte] of real;
tip2=array[1..4] of real;
tip3=array[1..4] of byte;
var n,i,k:byte;
s,c:tip1;
cm,sc,sr:tip2;
ncc:tip3;
procedure calc(k:byte);
begin
sc[k]:=sc[k]+s[i];
sr[k]:=sr[k]+s[i]*c[i];
if sc[k]<>0 then begin
cm[k]:=sr[k]/sc[k];
ncc[k]:=ncc[k]+1;
end;
end;
begin
write('Nr.de arborete=');readln(n);
for i:=1 to 4 do
begin
sc[i]:=0;
sr[i]:=0;
ncc[i]:=0;
end;
writeln('Precizati caracteristicile fiecarui arboret');
for i:=1 to n do
begin
writeln('Arboretul ',i,' :');
write('Suprafata=');readln(s[i]);
repeat
write('Consist.='); readln(c[i]);
until (c[i] >= 0) and (c[i] <= 1);
end;
for i:=1 to n do
begin
if c[i]<0.4 then calc(1)
else if c[i]<=0.6 then calc(2)
else if c[i]<=0.8 then calc(3)
else calc(4);
end;
for k:=1 to 4 do
begin
write('Categ.c. ',k);
if sc[k]<>0 then writeln(' Nr.arborete=',ncc[k],'; S.reala=',
sc[k]:1:1,' ha; cons.med=',cm[k]:1:2)
else writeln(' nu sint arborete');
end;
end.

Program descriere_parcelara_fisier:
type
date=record
ua: string[4];
supr: real;
vol: integer;

varsta: integer;
urgenta:integer;
specia: string[20];
end;
type
fis= file of date;
var
d:date;
fisam:fis;
a:string[4];
z:string[20];
x:real;
i,y,u,v:integer;
begin
assign(fisam,'C:\TP\descr.dat');
rewrite(fisam);
for i:=0 to 4 do
begin
assign(fisam,'C:\TP\descr.dat');
reset(fisam);
seek(fisam,i);
with d do
begin
writeln('Unitatea amenajistica nr. ',i+1);
write('ua=');
readln(a); ua:=a;
write('suprafata='); readln(x); supr:=x;
write('vol=');
readln(y); vol:=y;
write('varsta='); readln(v); varsta:=v;
write('urgenta='); readln(u); urgenta:=u;
write('specia='); readln(z); specia:=z;
write(fisam,d);
end;
close(fisam);
end;
end.

Program utilizare_fisier_descriere_parcelara;
type
date=record
ua:string[4];
supr:real;
vol,varsta,urgenta:integer;
specia:string[20];
end;
var
fisam:file of date;
i,j:integer;
d:date;
begin
assign(fisam,'C:\TP\descr.dat');
reset(fisam);
i:=0;
writeln('arboretul u.a. suprafata varsta compozitia');
writeln('************************************');
while not eof(fisam) do
begin
i:=i+1;
read(fisam,d);
with d do
begin

writeln(i:4,'
readln;
end;

',ua,'

',supr:4:1,'

',varsta,'

end;
close(fisam);
writeln('************************************');
end.

Program nivelment_trigonometric;
{ Calculul distantei cumulate si a cotei prin metoda
nivelmentului trigonometric }
type
date=array[byte] of real;
var
uv,di:date;
ci,o,dc,difc,cc:real;
i,n:byte ;
begin
write(Numar de picheti = );
readln(n);
write(Cota initiala = );
readln(ci);
for i:=1 to (n-1) do
begin
writeln(Pichetul ,i);
write(Unghi vert.= ); readln(uv[i]);
write(Dist. Incl.= ); readln(di[i]);
end;
dc:=0;
cc:=ci;
for i:=1 to (n-1) do
begin
uv[i]:=abs(uv[i]-200)-100;
uv[i]:=uv[i]*pi/200;
o:=di[i]*sqr(cos(uv[i]));
difc:=o*sin(uv[i])/cos(uv[i]);
dc:=dc+o;
cc:=cc+difc;
writeln(Pichet ,i+1, dist.cumul.=,dc:1:2,
cota=,cc:1:2);
end;
end.
Program suprafata_poligon;
{ Calculul suprafetei unui poligon
prin metoda analitica }
type
coord = array[byte] of real;
var
n,i,j,k: byte;
x,y: coord;
s: real;
begin
s:=0;
write('Numar de varfuri poligon=');
read(n);
for i:=1 to n do
begin
write('x(',i,')='); read(x[i]);

',specia);

write('y(',i,')='); read(y[i]);
end;
for i:=1 to n do
begin
j:=i-1;
if i=1
then
j:=n;
k:=i+1;
if k>n
then
k:=1;
s:=s+x[i]*(y[k]-y[j]);
end;
s:=abs(s/2);
writeln('Suprafata poligonului = ',s,' mp.');
end.

Program orientari;
{ Calculul orientarilor din coordonate }
uses crt;
type
coord= array[byte] of real;
var
n,i,j,k: byte;
x,y: coord;
teta: real;
cont: char;
begin
write('Numar de puncte='); read(n);
writeln('Coordonatele punctelor');
for i:=1 to n do
begin
write('x(',i,')='); read(x[i]);
write('y(',i,')='); read(y[i]);
end;
repeat
write ('Introdu simbolurile a doua puncte');
writeln(' pt.a calcula orientarea');
write('Primul punct ='); read(j);
write('Al doilea punct='); read(k);
if (x[k]>x[j]) and (y[k]>=y[j])
then
teta:=arctan((y[k]-y[j])/(x[k]-x[j]))*200/pi
else
if (x[k]<=x[j]) and (y[k]>y[j])
then
teta:=-arctan((x[k]-x[j])/(y[k]-y[j]))*200/pi+100
else
if (x[k]<x[j]) and (y[k]<=y[j])
then
teta:=arctan((y[k]-y[j])/(x[k]-x[j]))*200/pi+200
else
teta:=-arctan((x[k]-x[j])/(y[k]-y[j]))*200/pi+300;
write('Calculezi o noua orientare? (D/N):');
cont:=readkey;
until upcase(cont)='N';
end.

You might also like