解题思路: 先把读入的字符串全部转为大写,然后用循环对字符串进行查找,找到就储存位置,并且统计次数,最后输出,如果没有找到就输出 -1 。 程序: var word,article:ansistring; i,p,s,len:longint; begin readln(word); readln(article); word:=' '+upcase(word)+' '; article:=' '+upcase(article)+' '; p:=-1;s:=0; len:=length(word); for i:=1 to length(article)-len+1 do if copy(article,i,len)=word then begin if p=-1 then p:=i-1; inc(s); end; if p=-1 then write(p) else write(s,' ',p); end. 版权属于: Chris 原文地址: http://blog.sina.com.cn/s/blog_83ac6af80102v6ta.html 转载时必须以链接形式注明原始出处及本声明。