3 Aralık 2009 Perşembe

Matris kullanarak tanımlanan bir planın Pascal'a okutulması ve sonuçlarının bir dosyaya yazdırılması

Girdi Dosyası (plan.txt)

6 6
1 1 1 1 1 1
1 2 2 1 3 3
1 2 2 1 1 1
1 2 2 1 1 6
1 1 1 5 1 6
1 4 1 1 1 1


0.2 4.5 0.2 2.0 1.2 2.0
0.2 0.5 0.2 2.0 1.2 7.0

____________________________________________

Pascal Kodu

program alan;
uses crt;
type kat=array[1..30,1..30] of integer;
dizi=array[1..30] of real;
var m:kat;
x,y:dizi;
i,j,is,js:integer;
t,top,t1,t2,t3,t4,t5,t6:real;
plan,cikti:Text;
begin
clrscr;
assign(plan,'z:plan.txt');
assign(cikti,'z:cikti.txt');
reset(plan);
rewrite(cikti);
read(plan,is,js);
writeln(cikti,'sonuclar');
write(cikti,'is ve js degerleri:');
write(cikti,is:2,js:2);
writeln(cikti);
writeln(cikti,'konutun plan duzeni:');
for i:= 1 to is do
begin
for j:= 1 to js do
begin
read(plan,m[i,j]);
write(cikti,m[i,j]);
end;
writeln(cikti);
end;
write(cikti,'x[j]:');
for j:=1 to js do
begin
read(plan,x[j]);
write(cikti,x[j]:6:1);
end;
writeln(cikti);
write(cikti,'y[i]:');
for i:=1 to is do

begin
read(plan,y[i]);
write(cikti,y[i]:6:1);
end;
writeln(cikti);
t1:=0;
t2:=0;
t3:=0;
t4:=0;
t5:=0;
t6:=0;
for i:=1 to is do
begin
for j:=1 to js do
begin
if m[i,j]<>0 then
t:=x[j]*y[i];
case m[i,j] of
1:t1:=t1+t;
2:t2:=t2+t;
3:t3:=t3+t;
4:t4:=t4+t;
5:t5:=t5+t;
6:t6:=t6+t;
end;
end;
end;
top:=t1+t2+t3+t4+t5+t6;
writeln(cikti,'duvar alani:',t1:6:2);
writeln(cikti,'sirkulasyon alani:',t2:6:2);
writeln(cikti,'yasama alani:',t3:6:2);
writeln(cikti,'banyo alani:',t4:6:2);
writeln(cikti,'yatak odasi alani:',t5:6:2);
writeln(cikti,'cocuk odasi alani:',t6:6:2);
writeln(cikti,'toplam alan:', top:6:2);
writeln('program sona erdi');
close(cikti);
close(plan);
readln;
end.

____________________________________________


Çıktı Dosyası (cikti.txt)

sonuclar
is ve js degerleri: 6 6
konutun plan duzeni:
111111
122133
122111
122116
111516
141111
x[j]: 1.0 1.0 1.0 1.0 1.0 1.0
y[i]: 0.2 4.5 0.2 2.0 1.2 2.0
duvar alani: 31.80
sirkulasyon alani: 13.40
yasama alani: 9.00
banyo alani: 2.00
yatak odasi alani: 1.20
cocuk odasi alani: 3.20
toplam alan: 60.60

Hiç yorum yok:

Yorum Gönder