我一直在努力使這項工作一段時間。 我需要爲學校項目製作一個程序,該程序需要一個字符串並計算其中的對稱字。如何在字符串中找到對稱字?
裏面應該有句子,但任何幫助。無論我嘗試什麼方法,我似乎無法讓它工作。你能幫我嗎?
編輯:我當前的代碼
program rocnik;
var text:string;
word,drow:string[10];
i,j,k,p1:integer;
space,sym:boolean;
begin
p1:=0;
write('Enter text: ');readln(text);
if text<>'' then
begin
for i:=1 to length(text) do
begin
k:=0;
if space then
begin
j:=0;
space:=false;
end;
sym:=true;
if text[i]<>' ' then
begin
j:=j+1;
word[j]:=text[i];
end
else space:=true;
if space then
begin
space:=false;
for j:=1 to length(word) do
begin
k:=k+1;
drow[k]:=word[j];
if drow[k]<>word[j] then sym:=false;
end;
end;
if space and sym then p1:=p1+1;
end;
end
else writeln('You didnt enter any text');
writeln('there are ',p1,' symmetrical words in text');
readln;
end.
如果您不提供任何代碼,幫助是可疑的。 – doug65536
對不起,添加了我的當前代碼 – Piskot