please, can someone check my code and tell me why it isn't working
my code:
program most_common_word;
var s : array [1..10001] of char;
s1,ispis : string;
rij : array [1..1001] of string;
a,b,c,d,x,y,i,p : longint;
label
van;
begin
readln(s);
s1:='';
p:=1;
for i:=1 to 1000 do begin
a:=0;
if (ord(upcase(s[i]))>64) and (ord(upcase(s[i]))<91) then begin
if lowercase(s[i])='a' then s1:=s1+'a';
if lowercase(s[i])='b' then s1:=s1+'b';
if lowercase(s[i])='c' then s1:=s1+'c';
if lowercase(s[i])='d' then s1:=s1+'d';
if lowercase(s[i])='e' then s1:=s1+'e';
if lowercase(s[i])='f' then s1:=s1+'f';
if lowercase(s[i])='g' then s1:=s1+'g';
if lowercase(s[i])='h' then s1:=s1+'h';
if lowercase(s[i])='i' then s1:=s1+'i';
if lowercase(s[i])='j' then s1:=s1+'j';
if lowercase(s[i])='k' then s1:=s1+'k';
if lowercase(s[i])='l' then s1:=s1+'l';
if lowercase(s[i])='m' then s1:=s1+'m';
if lowercase(s[i])='n' then s1:=s1+'n';
if lowercase(s[i])='o' then s1:=s1+'o';
if lowercase(s[i])='p' then s1:=s1+'p';
if lowercase(s[i])='q' then s1:=s1+'q';
if lowercase(s[i])='r' then s1:=s1+'r';
if lowercase(s[i])='s' then s1:=s1+'s';
if lowercase(s[i])='t' then s1:=s1+'t';
if lowercase(s[i])='u' then s1:=s1+'u';
if lowercase(s[i])='v' then s1:=s1+'v';
if lowercase(s[i])='w' then s1:=s1+'w';
if lowercase(s[i])='x' then s1:=s1+'x';
if lowercase(s[i])='y' then s1:=s1+'y';
if lowercase(s[i])='z' then s1:=s1+'z';
a:=1;
end;
if a=0 then begin
if s1<>'' then begin rij[p]:=s1; inc(p); s1:=''; end;
end;
end;
c:=0;
for i:=1 to p-1 do begin
d:=0;
for x:=1 to p-1 do if rij[x]=rij[i] then inc(d);
if d>c then begin c:=d; ispis:=rij[i]; end;
end;
Str(c,s1);
ispis:=ispis+' '+s1;
writeln(ispis);
end.
thanks!
my code:
program most_common_word;
var s : array [1..10001] of char;
s1,ispis : string;
rij : array [1..1001] of string;
a,b,c,d,x,y,i,p : longint;
label
van;
begin
readln(s);
s1:='';
p:=1;
for i:=1 to 1000 do begin
a:=0;
if (ord(upcase(s[i]))>64) and (ord(upcase(s[i]))<91) then begin
if lowercase(s[i])='a' then s1:=s1+'a';
if lowercase(s[i])='b' then s1:=s1+'b';
if lowercase(s[i])='c' then s1:=s1+'c';
if lowercase(s[i])='d' then s1:=s1+'d';
if lowercase(s[i])='e' then s1:=s1+'e';
if lowercase(s[i])='f' then s1:=s1+'f';
if lowercase(s[i])='g' then s1:=s1+'g';
if lowercase(s[i])='h' then s1:=s1+'h';
if lowercase(s[i])='i' then s1:=s1+'i';
if lowercase(s[i])='j' then s1:=s1+'j';
if lowercase(s[i])='k' then s1:=s1+'k';
if lowercase(s[i])='l' then s1:=s1+'l';
if lowercase(s[i])='m' then s1:=s1+'m';
if lowercase(s[i])='n' then s1:=s1+'n';
if lowercase(s[i])='o' then s1:=s1+'o';
if lowercase(s[i])='p' then s1:=s1+'p';
if lowercase(s[i])='q' then s1:=s1+'q';
if lowercase(s[i])='r' then s1:=s1+'r';
if lowercase(s[i])='s' then s1:=s1+'s';
if lowercase(s[i])='t' then s1:=s1+'t';
if lowercase(s[i])='u' then s1:=s1+'u';
if lowercase(s[i])='v' then s1:=s1+'v';
if lowercase(s[i])='w' then s1:=s1+'w';
if lowercase(s[i])='x' then s1:=s1+'x';
if lowercase(s[i])='y' then s1:=s1+'y';
if lowercase(s[i])='z' then s1:=s1+'z';
a:=1;
end;
if a=0 then begin
if s1<>'' then begin rij[p]:=s1; inc(p); s1:=''; end;
end;
end;
c:=0;
for i:=1 to p-1 do begin
d:=0;
for x:=1 to p-1 do if rij[x]=rij[i] then inc(d);
if d>c then begin c:=d; ispis:=rij[i]; end;
end;
Str(c,s1);
ispis:=ispis+' '+s1;
writeln(ispis);
end.
thanks!