PASCAL程序里如何求极角?就是在求凸包时,以左下点(设为x0,y0)为极点,将其余点按极角排序,那对于某个点的极角(X,Y)怎么表示?貌似要用到反三角函数.
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 06:48:56
PASCAL程序里如何求极角?就是在求凸包时,以左下点(设为x0,y0)为极点,将其余点按极角排序,那对于某个点的极角(X,Y)怎么表示?貌似要用到反三角函数.
PASCAL程序里如何求极角?
就是在求凸包时,以左下点(设为x0,y0)为极点,将其余点按极角排序,那对于某个点的极角(X,Y)怎么表示?貌似要用到反三角函数.
PASCAL程序里如何求极角?就是在求凸包时,以左下点(设为x0,y0)为极点,将其余点按极角排序,那对于某个点的极角(X,Y)怎么表示?貌似要用到反三角函数.
附图解
program jisuanqi;
var nextch:char;
result:real;
procedure readnextch;
begin
repeat
if eoln then nextch:=';'
else begin
read(nextch);
write(nextch);
end;
until nextch<>'';
end;
procedure readnumber(var number:real);
var scale:real;
begin
number:=0;
while nextch in['0'..'9'] do
begin
number:=number*10+ord(nextch)-ord('0');
readnextch;
end;
if nextch='.' then begin
scale:=1;
readnextch;
while nextch in['0'..'9'] do
begin
number:=number*10+ord(nextch)-ord('0');
scale:=scale*10;
readnextch;
end;
number:=number/scale;
end;
end;
procedure readexpression(var exprvalue:real);
var addop:char;
nexttermval:real;
procedure readterm(var termvalue:real);
var mulop:char;
nextfacval:real;
procedure readfactor(var factorvalue:real);
begin
if nextch in['0'..'9'] then readnumber(factorvalue)
else if nextch='(' then begin
readnextch;
readexpression(factorvalue);
if nextch=')' then readnextch
else writeln('error');
end
else begin
writeln('error');
factorvalue:=1;
end;
end;
begin
readfactor(termvalue);
while nextch in ['*','/'] do
begin
mulop:=nextch;
readnextch;
readfactor(nextfacval);
case mulop of
'*':termvalue:=termvalue*nextfacval;
'/':termvalue:=termvalue/nextfacval;
end;
end;
end;
begin
readterm(exprvalue);
while nextch in ['+','-'] do
begin
addop:=nextch;
readnextch;
readterm(nexttermval);
case addop of
'+':exprvalue:=exprvalue+nexttermval;
'-':exprvalue:=exprvalue-nexttermval;
end;
end;
end;
begin
readnextch;
readexpression(result);
writeln('=',result:20:6);
end.