procedure TForm3.Button1Click(Sender: TObject);
var a:string;
m,n,i:integer;
begin
a:='my ,name .is : tom?';
m:=0;
n:=0;
for i:=1 to length(a) do //注意,STRING类型是从1开始计数的。
begin
if ( a[i] in ['a'..'z'] ) then m:=m+1;
if not ( a[i] in ['a'..'z'] ) then n:=n+1;
// if not ( a[i] in [' ',',','.',':','?'] ) then m:=m+1;
// if ( a[i] in [' ',',','.',':','?'] ) then n:=n+1;
end;
showmessage(inttostr(m));
showmessage(inttostr(n));
end;
网友评论