to: rjiajia
我加了个小数点
function a(s: string): boolean;
var s1,c:string;p,i,cn1,cn2:integer; r:boolean;
begin
r:=true;
s1:='1234567890+-*/().';
c:='';cn1:=0;cn2:=0;
for i:=1 to length(s) do
begin
p:=pos(s,s1);
case p of
0:r:=false;
1..10:c:=c+'1';
11..14:c:=c+'2';
15:begin c:=c+'3';cn1:=cn1+1;end;
16:begin c:=c+'4';cn2:=cn2+1;end ;
17:c:=c+'5';
end;
end;
if c[1] in ['2','5'] then
r:=false;
if c[length(c)] in ['2','5'] then
r:=false;
if (pos('25',c)>0) or (Pos('35',c)>0) or (Pos('45',c)>0) then
r:=false;
if (pos('52',c)>0) or (Pos('53',c)>0) or (Pos('54',c)>0) then
r:=false;
if pos('22',c)>0 then
r:=false;
if pos('34',c)>0 then
r:=false;
if pos('32',c)>0 then
r:=false;
if pos('24',c)>0 then
r:=false;
if pos('13',c)>0 then
r:=false;
if pos('41',c)>0 then
r:=false;
if cn1<>cn2 then
r:=false;
result:=r;
end;
谢谢大家参与!