统计单词个数 pascal代码告诉样例输入 Sample Input Hello everybody!Vivian Snow is the greatest alive.样例输出 Sample Output 8 时间限制 Time Limitation 1s请无视Sample Input
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 14:10:46
统计单词个数 pascal代码告诉样例输入 Sample Input Hello everybody!Vivian Snow is the greatest alive.样例输出 Sample Output 8 时间限制 Time Limitation 1s请无视Sample Input
统计单词个数 pascal代码
告诉
样例输入 Sample Input
Hello everybody!Vivian Snow is the greatest alive.
样例输出 Sample Output
8
时间限制 Time Limitation
1s
请无视Sample Input
统计单词个数 pascal代码告诉样例输入 Sample Input Hello everybody!Vivian Snow is the greatest alive.样例输出 Sample Output 8 时间限制 Time Limitation 1s请无视Sample Input
var s:string;
i,j,t:integer;
begin
readln(s);
for i:=1 to length(s) do
if (s[i]<'A')and(s[i]>'Z')and(s[i]<'a')and(s[i]>'z')
and(s[i]<>' ') then s[i]:=' ';
j:=pos(' ',s);
while j>0 do begin
if s[j+1]=' ' then while s[j+1]=' ' do delete(s,j+1,1);
j:=pos(' ',copy(s,j+1,255));
end;
j:=1;
for i:=1 to length(s) do
if s[i]=' ' then inc(j);
writeln(j);
end.