Text
Text
uses crt;
label lap;
Var m,b,z1,z2,d1,d2,de1,de2,Re,dae1,dae2,df1,df2,ss,
da1,da2,t,he,hte,hae1,hae2,hfe1,hfe2,tetaf1,tetaf2,beta,x:real;
ck,cork,ch:Char;
i,n,dem:integer;
PROCEDURE TINH_DICH_CHINH;
label lai,tiep_z2,tiep_aw;
Procedure Thongbao;
Begin
TEXTCOLOR(4);
Writeln('XIN CAM ON BAN RAT NHIEU');
end;
VAR B:ARRAY[1..40]OF REAL;
i,j,a,c,n,dem:integer;
m,aw,awt,da1,da2,z1,z2,zt,y,dy,kx,ky,x1,x2,xt:real;
cork,ch :char;
kt:boolean;
Begin clrscr;
B[1]:=0.009;B[2]:=0.032;B[3]:=0.064;B[4]:=0.122;B[5]:=0.191;
B[6]:=0.265;B[7]:=0.350;B[8]:=0.445;B[9]:=0.568;B[10]:=0.702;
B[11]:=0.844;B[12]:=1.020;B[13]:=1.180;B[14]:=1.354;B[15]:=1.542;
B[16]:=1.752;B[17]:=1.970;B[18]:=2.240;B[19]:=2.445;B[20]:=2.670;
B[21]:=2.930;B[22]:=3.215;B[23]:=3.475;B[24]:=3.765;B[25]:=4.070;
B[26]:=4.430;B[27]:=4.760;B[28]:=5.070;B[29]:=5.420;B[30]:=5.760;
B[31]:=6.120;B[32]:=6.470;B[33]:=6.840;B[34]:=7.190;B[35]:=7.600;
B[36]:=8.010;B[37]:=8.400;B[38]:=8.810;B[39]:=9.420;B[40]:=9.670;
TEXTCOLOR(6);
WriteLN(' CHAO BAN DA DEN VOI CHUONG TRINH TINH TOAN HE SO DICH CHINH CHO ');
Writeln(' CAP BANH RANG DE DAM BAO MOT KHOANG CACH TRUC DA DINH TRUOC.');
Writeln(' =======================================================');
TEXTCOLOR(15);
Write(' Hay nhap vao so lan tinh: n=');Readln(n);
dem:=0;
Begin
lai:textcolor(15);
Write(' Hay nhap vao modun cua banh rang m='); readln(m);
if (m=1.25)or(m=1.375)or(m=2)or(m=2.25)or(m=2.5)or(m=3)or(m=3.5)or(m=4)or
(m=4.5)or(m=5)or(m=5.5)or(m=6)or(m=7)or(m=8)or
(m=9)or(m=10)or(m=11)or(m=12)or(m=14) then kt:=false else kt:=true;
if kt then
begin
Textcolor(5);
Write(' Ban da nhap modum phi tieu chuan! Ban phai nhap modun tieu chuan!');
Textcolor(15);
goto lai;
end;
Write(' Hay nhap vao so rang banh ramg thu nhat: z1='); readln(z1);
While z1<17 do
Begin
Textcolor(5);
Writeln(' Ban da nhap so rang z1< Zmin => Se co hien tuong cat lem xay ra');
Writeln(' Ban da chac chan voi thong so nay chua?');
Write(' Neu chac chan ban hay bam "ENTER";Bam phim bat ky de tiep tuc');
Textcolor(15);
ch:=readkey;if ch=#13 then goto tiep_z2;
Write(' Moi ban nhap lai voi z1=');readln(z1);
end;
Tiep_z2:
Write(' Hay nhap vao so rang banh ramg thu hai: z2='); readln(z2);
While z2<17 do
Begin
Textcolor(5);
Writeln(' Ban da nhap so rang z1< Zmin => Se co hien tuong cat lem xay ra');
Writeln(' Ban da chac chan voi thong so nay chua?');
Write(' Neu chac chan ban hay bam "ENTER";Bam phim bat ky de tiep tuc');
Textcolor(15);
ch:=readkey;if ch=#13 then goto tiep_aw;
Write(' Moi ban nhap lai voi z2=');readln(z2);
end;
Tiep_aw:
Write(' Hay nhap vao khoang cach truc:aw=');readln(aw);
While aw=0 do
Begin
Textcolor(5);
Writeln(' Ban da nhap chieu rong vanh rang b=0; Ban phai nhap he so nay khac 0');
Textcolor(15);
Write(' Moi ban nhap lai voi aw=');readln(aw);
end;
zt:=(z1+z2);
y:=aw/m-0.5*zt;
ky:=1000*y/zt;
a:=1;i:=1;
awt:=0.5*m*zt;
repeat
if i < ky then a:=i;c:=i+1;i:=i+1;
until i > ky;
if ky < 1 then kx:= B[1];
if ky = 0 then kx:= 0
else
kx:=(ky-a)*(B[c]-B[a])+B[a];
dy:=kx*zt/1000;
xt:=y+dy;
x1:=0.5*(xt-(z2-z1)*y/zt);
x2:=xt-x1;da1:=(m*z1+2*(1+x1-dy)*m);da2:=(m*z2+2*(1+x1-dy)*m);
If (x1=0)and(x2=0) then
Begin
textcolor(6);
Writeln(' KET QUA TINH TOAN');
Writeln(' *********************');
Writeln(' Cap banh rang khong dich chinh')
end
else
Begin clrscr;
Textcolor(3);
Writeln(' BANG KET QUA TINH TOAN NHU SAU');
Writeln(' ====================================');
Textcolor(6);
Write(#218);FOR I:=1 TO 15 DO WRITE(#196); Write(#194);FOR I:=1 TO 46 DO WRITE(#196);
Write(#194);
FOR I:=1 TO 13 DO WRITE(#196); Writeln(#191);
Write(#179);FOR I:=1 TO 15 DO WRITE(' ');Write(#179);Write(' Modun cap banh rang:
');Write(#179);
Write(' m= ',m:9:3);Writeln(#179);
Write(#179);FOR I:=1 TO 15 DO WRITE(' '); Write(#195); FOR I:=1 TO 46 DO
WRITE(#196);Write(#197);
FOR I:=1 TO 13 DO WRITE(#196); Writeln(#180);
Write(#179);Write(' Thong so ');Write(#179);Write(' Khoang cach truc can dat:
');
Write(#179); Write(' aw=',aw:9:3);Writeln(#179);
Write(#179); FOR I:=1 TO 15 DO WRITE(' ');Write(#195);FOR I:=1 TO 46 DO
WRITE(#196);Write(#197);
FOR I:=1 TO 13 DO WRITE(#196); Writeln(#180);
Write(#179);Write(' dau vao ');Write(#179);Write(' So rang cua banh rang thu nhat:
');
Write(#179);Write(' z1=',z1:9:3);Writeln(#179);
Write(#179); FOR I:=1 TO 15 DO WRITE(' ');Write(#195);FOR I:=1 TO 46 DO
WRITE(#196);Write(#197);
FOR I:=1 TO 13 DO WRITE(#196); Writeln(#180);
Write(#179);FOR I:=1 TO 15 DO WRITE(' ');Write(#179);Write(' So rang cua banh rang thu hai:
');
Write(#179); Write(' z2=',z2:9:3); Writeln(#179);
Write(#195); FOR I:=1 TO 15 DO WRITE(#196); Write(#197);FOR I:=1 TO 46 DO
WRITE(#196);Write(#197);
FOR I:=1 TO 13 DO WRITE(#196); Writeln(#180);
Write(#179);FOR I:=1 TO 15 DO WRITE(' ');Write(#179);Write(' Khoang cach truc chia:
');
Write(#179); Write(' a= ',awt:9:3); Writeln(#179);
Write(#179); FOR I:=1 TO 15 DO WRITE(' '); Write(#195);FOR I:=1 TO 46 DO
WRITE(#196);Write(#197);
FOR I:=1 TO 13 DO WRITE(#196); Writeln(#180);
Write(#179);Write(' Thong so ');Write(#179);Write(' Duong kinh ding cua banh rang thu
nhat: ');
Write(#179); Write(' da1=',da1:8:3);Writeln(#179);
Write(#179); FOR I:=1 TO 15 DO WRITE(' '); Write(#195);FOR I:=1 TO 46 DO
WRITE(#196);Write(#197);
FOR I:=1 TO 13 DO WRITE(#196); Writeln(#180);
Write(#179);FOR I:=1 TO 15 DO WRITE(' ');Write(#179);Write(' Duong kinh dinh cua banh rang
thu hai: ');
Write(#179); Write(' da2=',da2:8:3); Writeln(#179);
Write(#179); FOR I:=1 TO 15 DO WRITE(' '); Write(#195);FOR I:=1 TO 46 DO
WRITE(#196);Write(#197);
FOR I:=1 TO 13 DO WRITE(#196); Writeln(#180);
Write(#179);Write(' dau ra ');Write(#179);Write(' He so dich chinh cua banh rang thu
nhat: ');
Write(#179); Write(' x1=',x1:9:3);Writeln(#179);
Write(#179); FOR I:=1 TO 15 DO WRITE(' '); Write(#195);FOR I:=1 TO 46 DO
WRITE(#196);Write(#197);
FOR I:=1 TO 13 DO WRITE(#196); Writeln(#180);
Write(#179);FOR I:=1 TO 15 DO WRITE(' ');Write(#179);Write(' He so dich chinh cua banh rang
thu hai: ');
Write(#179); Write(' x2=',x2:9:3);Writeln(#179);
Write(#192);FOR I:=1 TO 15 DO WRITE(#196); Write(#193);FOR I:=1 TO 46 DO WRITE(#196);
Write(#193);
FOR I:=1 TO 13 DO WRITE(#196); Writeln(#217);TEXTCOLOR(15);
end;
dem:=dem+1;
if dem = n then
Begin
textcolor(5);
Writeln(' BAN DA HOAN THANH ',dem,' LAN TINH');TEXTCOLOR(15);
THONGBAO; exit;
end;
Begin
Textcolor(5);
Writeln(' Ban co muon tinh tiep hay khong?C/K');
Writeln(' Hay bam phim bat ky neu nhu ban muon tinh tiep lan thu ',dem+1);
Writeln(' Hay bam phim "K" neu nhu ban muon dung bay gio');
End;
read(cork);
if keypressed then cork:= readkey;
if upcase(cork)='K' then
begin
THONGBAO;exit;
end else goto lai
end;THONGBAO;
end;
{//////////////////////////////////////////////////////////////////////////}
Procedure Gioi_thieu;
Begin
Textcolor(4);
Writeln(' DAY LA CHUONG TRINH TINH TOAN CAC THONG SO KY THUAT CHO BANH RANG');
Writeln(' NGUOI TRINH BAY : NGUYEN THAC DONG LOP CTM1');
Writeln(' GIAO VIEN HUONG DAN: PHI TRONG HAO');
Writeln(' ==========================================');
end;
{///////////////////////////////////////////////////////////////////////////}
Procedure Chon;
begin
textcolor(6);
Writeln(' BAN HAY LUA CHON CAC PHAN TINH THEO PHIM BAN CHON');
Writeln(' LUA CHON PHIM "1" VA BAM ENTER NEU NHU GOC GIUA HAI DUONG TRUC KHAC 90 DO');
Writeln(' LUA CHON PHIM "2" VA BAM ENTER NEU NHU GOC GIUA HAI DUONG TRUC LA 90 DO');
Write(' LUA CHON PHIM BAT KY VA BAM ENTER NEU NHU BAN MUON TINH BR TRU DICH CHINH');
readln(ck);
end;
{//////////////////////////////////////////////////////////////////////////}
Procedure Thong_bao;
begin
textcolor(6);
Write(' Do gioi han cua thoi gian nen phan nay chua duoc trinh bay, neu co ');
Writeln(' dieu kien ve thoi gian toi se trinh bay de cac ban tham khao.');
Write(' CHUONG TRINH SE DUNG LAI SAU MOT CHUT THOI GIAN, BAN CAN CHAY LAI CHUONG TRINH VOI
NHANH KHAC.');
DELAY (15000);textcolor(15);halt;
end;
{//////////////////////////////////////////////////////////////////////////}
Procedure Nhap;
label lai,tiep_z2,tiep_b;
var kt:boolean;
Begin
lai:
Write(' Hay nhap vao modun cua banh rang m='); readln(m);
if (m=1.25)or(m=1.375)or(m=2)or(m=2.25)or(m=2.5)or(m=3)or(m=3.5)or(m=4)or
(m=4.5)or(m=5)or(m=5.5)or(m=6)or(m=7)or(m=8)or
(m=9)or(m=10)or(m=11)or(m=12)or(m=14) then kt:=false else kt:=true;
if kt then
begin
Textcolor(5);
Writeln(' Ban da nhap modum phi tieu chuan! Ban phai nhap modun tieu chuan!');
Textcolor(15);
goto lai;
end;
Write(' Hay nhap vao so rang banh ramg thu nhat: z1='); readln(z1);
While z1<17 do
Begin
Textcolor(5);
Writeln(' Ban da nhap so rang z1< Zmin => Se co hien tuong cat lem xay ra');
Writeln(' Ban da chac chan voi thong so nay chua?');
Write(' Neu chac chan ban hay bam "ENTER";Bam phim bat ky de tiep tuc');
Textcolor(15);
ch:=readkey;if ch=#13 then goto tiep_z2;
Write(' Moi ban nhap lai voi z1=');readln(z1);
end;
Tiep_z2:
Write(' Hay nhap vao so rang banh ramg thu hai: z2='); readln(z2);
While z2<17 do
Begin
Textcolor(5);
Writeln(' Ban da nhap so rang z1< Zmin => Se co hien tuong cat lem xay ra');
Writeln(' Ban da chac chan voi thong so nay chua?');
Write(' Neu chac chan ban hay bam "ENTER";Bam phim bat ky de tiep tuc');
Textcolor(15);
ch:=readkey;if ch=#13 then goto tiep_b;
Write(' Moi ban nhap lai voi z2=');readln(z2);
end;
Tiep_b:
Write(' Hay nhap vao chieu rong vanh rang: b='); readln(b);
While b=0 do
Begin
Textcolor(5);
Writeln('Ban da nhap chieu rong vanh rang b=0; Ban phai nhap he so nay khac 0');
Textcolor(15);
Write(' Moi ban nhap lai voi b=');readln(b);
end;
Writeln(' Bamh rang co dich chinh hay khong?C/K');
Writeln(' Chon phim "C" va bam enter neu nhu banh rang co dich chinh');
Write(' Chon phim bat ky va bam enter neu nhu banh rang khong dich
chinh');readln(ck);
if keypressed then ck:= readkey;
if upcase(ck)=('C') then
Begin
Write(' Nhap vao he so dich chinh:x=');readln(x);
end
else exit;
End;
{////////////////////////////////////////////////////////////////////////////}
Procedure Tinh;
Begin
beta:=0; { Goc nghieng cua banh rang }
Re:=0.5*m*sqrt((sqr(z1)+sqr(z2)));{Cchieu dai con ngoai}
de1:=m*z1;{Duong kinh chia ngoai cua banh rang thu nhat}
de2:=m*z2;{Duong kinh chia ngoai cua banh rang thu hai}
d1:=arctan(z1/z2);{Goc con chia cua banh rang thu nhat}
d2:=pi/2-d1;{Goc con chia cua banh rang thu hai}
hte:=cos(beta);
he:=hte*2*m+0.2*m;{Chieu cao rang ngoai}
hae1:=(hte+x*hte)*m;{Chieu cao dau rang ngoai cua banh rang thu nhat}
hae2:=(2*hte*m-hae1);{Chieu cao dau rang ngoai cua banh rang thu hai}
hfe1:=(he-hae1);{Chieu cao chan rang cua banh rang thu nhat}
hfe2:=he-hae2;{Chieu cao chan rang cua banh rang thu hai}
tetaf1:=(arctan(hfe1/Re));{Goc chan rang cua banh rang thu nhat}
tetaf2:=(arctan(hfe2/Re)); {Goc chan rang cua banh rang thu hai}
da1:=d1+tetaf1;{Goc con dinh cua banh rang thu nhat}
da2:=d2+tetaf2;{Goc con dinh cua banh rang thu hai}
df1:=d1-tetaf1;{Goc chan rang cua banh rang thu nhat}
df2:=d2-tetaf2;{Goc chan rang cua banh rang thu hai}
dae1:=de1+2*hae1*cos(d1);{Duong kinh dinh rang ngoai cua banh rang thu nhat}
dae2:=de2+2*hae2*cos(d2);{Duong kinh dinh rang ngoai cua banh rang thu hai}
d1:=d1*180/pi;{Chuyen goc tu dang thap phan sang dang do}
d2:=d2*180/pi;
da1:=da1*180/pi;
da2:=da2*180/pi;
df1:=df1*180/pi;
df2:=df2*180/pi;
End;
{///////////////////////////////////////////////////////////////////////////}
Procedure Xuat;
Begin
Writeln(' BANG KET QUA TINH TOAN NHU SAU');{Ke bang de ghi ket qua}
Writeln(' ****************************');
Write(#218);FOR I:=1 TO 50 DO WRITE(#196); Write(#194);FOR I:=1 TO 20 DO WRITE(#196);
Writeln(#191);
Write(#179);Write(' Chieu dai con dinh cua cap banh rang: '); Write(#179);
Write(' Re=',Re:7:2);Write('(mm) ');
Writeln(#179);
Write(#195); FOR I:=1 TO 50 DO WRITE(#196);Write(#197);FOR I:=1 TO 20 DO WRITE(#196);
Writeln(#180);
Write(#179);Write(' Goc con chia cua banh rang thu nhat: '); Write(#179);
Write(' d1=',int(d1):3:0,'do',frac(d1)*60:2:0,'phut ');
Writeln(#179);
Write(#195);FOR I:=1 TO 50 DO WRITE(#196); Write(#197);FOR I:=1 TO 20 DO WRITE(#196);
Writeln(#180);
Write(#179);Write(' Goc con chia cua banh rang thu hai: ');Write(#179);
Write(' d2=',int(d2):3:0,'do',frac(d2)*60:2:0,'phut '); Writeln(#179);
Write(#195);FOR I:=1 TO 50 DO WRITE(#196); Write(#197);FOR I:=1 TO 20 DO WRITE(#196);
Writeln(#180);
Write(#179);Write(' Goc con dinh banh rang thu nhat: '); Write(#179);
Write(' da1=',int(da1):3:0,'do',frac(da1)*60:2:0,'phut '); Writeln(#179);
Write(#195);FOR I:=1 TO 50 DO WRITE(#196); Write(#197);FOR I:=1 TO 20 DO WRITE(#196);
Writeln(#180);
Write(#179);Write(' Goc con dinh banh rang thu hai: '); Write(#179);
Write(' da2=',int(da2):3:0,'do',frac(da2)*60:2:0,'phut '); Writeln(#179);
Write(#195); FOR I:=1 TO 50 DO WRITE(#196);Write(#197);FOR I:=1 TO 20 DO WRITE(#196);
Writeln(#180);
Write(#179);Write(' Goc con day banh rang thu nhat: '); Write(#179);
Write(' df1=',int(df1):3:0,'do',frac(df1)*60:2:0,'phut '); Writeln(#179);
Write(#195); FOR I:=1 TO 50 DO WRITE(#196);Write(#197);FOR I:=1 TO 20 DO WRITE(#196);
Writeln(#180);
Write(#179);Write(' Goc con day banh rang thu hai: '); Write(#179);
Write(' df2=',int(df2):3:0,'do',frac(df2)*60:2:0,'phut '); Writeln(#179);
Write(#195); FOR I:=1 TO 50 DO WRITE(#196);Write(#197);FOR I:=1 TO 20 DO WRITE(#196);
Writeln(#180);
Write(#179);Write(' Duong kinh dinh con ngoai banh rang thu nhat: '); Write(#179);
Write(' dae1=',dae1:7:2,'(mm) '); Writeln(#179);
Write(#195); FOR I:=1 TO 50 DO WRITE(#196);Write(#197);FOR I:=1 TO 20 DO WRITE(#196);
Writeln(#180);
Write(#179);Write(' Duong kinh dinh con ngoai banh rang thu hai : '); Write(#179);
Write(' dae2=',dae2:7:2,'(mm) '); Writeln(#179);
Write(#192);FOR I:=1 TO 50 DO WRITE(#196); Write(#193);FOR I:=1 TO 20 DO WRITE(#196);
Writeln(#217);Textcolor(15);
end;
{////////////////////////////////////////////////////////////////////////////}
Procedure Thong_bao1;
Begin
Textcolor(2);
Writeln(' XIN CAM ON BAN RAT NHIEU');
Textcolor(15);write(' ');
End;
{////////////////////////////////////////////////////////////////////////////}
BEGIN {CHUONG TRINH CHINH}
dem:=0;
clrscr;
Gioi_thieu;
Chon;
if upcase(ck) = '1' then Thong_bao
ELSE if upcase(ck) ='2' then
begin {Doan chuong trinh tinh cho BR con}
Textcolor(15);
Write(' Ban muon tinh bao nhieu lan? Hay nhap vao so lan can tinh:n=');read(n);
If n = 0 then
begin
Textcolor(5);
Writeln(' BAN CHUA TINH TOAN CHUT NAO! MOI BAN HAY CHAY LAI CHOUNG TRINH');
exit;Textcolor(15);Write(' ');
end else
lap:
While dem < n do
begin
Nhap;
Tinh;
Xuat;
dem:=dem+1;
if dem = n then
begin
Thong_bao1;exit;
end else
Begin
Writeln(' Ban co muon tinh tiep hay khong?C/K');
Writeln(' Hay bam "ENTER" de tiep tuc lan ',dem+1,'');
Writeln(' Hay bam phim "K" neu nhu ban muon thoat');
read(cork);
end;
if keypressed then
cork:= readkey;
if upcase(cork) ='K' then
Begin
Thong_bao1;exit;
end;
if cork =#13 then goto lap;
End;{Ket thuc tinh BR con}
END
else TINH_DICH_CHINH;
END.