|
|
back to boardI've got WA #7. Help me, please! Posted by felfer 14 Dec 2011 01:36 const N=50; type TChastot=array [1..N] of byte; var inStr,outStr:string; chast:TChastot; i,j:integer; maxChast,iPos:integer; begin readln(inStr); for i:=1 to length(inStr) do begin chast[i]:=0; for j:=i to length(inStr) do if inStr[i]=inStr[j] then chast[i]:=chast[i]+1; end; maxChast:=Low(integer); iPos:=0; for i:=1 to length(inStr) do if maxChast<chast[i] then begin maxChast:=chast[i]; iPos:=i; end; i:=iPos; outStr:=''; while (i<=length(inStr)) and (chast[i]=chast[iPos]) do begin outStr:=outStr+inStr[i]; i:=i+1; end; if length(outStr)<length(inStr) then begin i:=pos(outStr,copy(inStr,length(outStr)+1,length(inStr)-length(outStr))); while i=0 do begin delete(outStr,length(outStr),1); i:=pos(outStr,copy(inStr,length(outStr)+1,length(inStr)-length(outStr))); end; end; writeln(outStr); end. Edited by author 14.12.2011 02:20 |
|
|