pascal与一元一次方程

来源:百度知道 编辑:UC知道 时间:2024/06/22 20:54:11
如何用pascal解一元一次方程?属于什么结构的程序?要用到那些语句?还请高明人士赐教!
例:1/2x-5=10 用pascal语言把程序完整地写出来,多谢了!!!

program lkkjzp;
var
y,s,st,str:string;
kx,n,kc,k,z:int64;
i,j:longint;
code:integer;
t:real;
begin
readln(s);
while s<>'' do
begin
for i:=1 to length(s) do
if s[i] in ['a'..'z'] then y:=s[i];
j:=1;
kx:=0;
kc:=0;
code:=0;
for i:=1 to pos('=',s) do
begin
if ((s[i]='+') or (s[i]='-') or (s[i]='=')) and(i<>1) then
begin
str:=copy(s,j,i-j);
val(str,k,code);
if code=0 then kc:=kc-k;
if code<>0 then
begin
delete(str,code,1);
if str='' then k:=1 else
val(str,k,code);
if code<>0 then
if str[1]='+' then k:=1 else if str[1]='-'then k:=-1;
kx:=kx+k;
end;
j:=i;
end;
end;
code: