pascal40分,貌似是输入问题?
查看原帖
pascal40分,貌似是输入问题?
374402
pooooo楼主2021/1/17 09:26

第5测试点上没有换行?,读入不了第二行数据,求解

var
  s,s1,ss:string;
  p:boolean;
  i,xx,num:longint;
begin
  readln(s);
  s:=lowercase(s);
  readln(s1);
  s1:=lowercase(s1);
  s1:=s1+' ';
  p:=true;
  xx:=-1;
  for i:=1 to length(s1) do
   if s1[i]<>' ' then ss:=ss+s1[i]
     else 
	   begin 
		if ss=s then 
	    begin
		  inc(num);
		  if p then
			 begin 
         p:=false; 
         xx:=xx+i-length(s);                    end;
		 end;
		ss:='';
		end;
  if num<>0 then writeln(num,' ',xx) 
         else writeln('-1');
end.
2021/1/17 09:26
加载中...