用pascal编写的我的回文程序给了我随机答案..检查我的代码

时间:2015-03-02 17:35:01

标签: pascal palindrome

program ideone;
var 
    s : string;
    t,len,i,j,count : integer;
begin
    readln(t);

    while t>0 do
    begin
        read(s);

        len := byte(s[0]);

        i :=0;
        j :=len-1;
        count :=0;

        while i<j do
        begin

            if s[i]<>s[j] then
            begin
                count :=count+1;
                    if count>1 then
                    begin
                        writeln('no');
                        break;
                    end;
            end;

            i :=i+1;
            j :=j-1;
        end;

        if count<2 then
            writeln('yes');

        t := t-1;
    end;

end.

我必须检查是否只更改给定字符串中的一个字符可以使其成为'Palindrome'...

INPUT: 3 阿罗拉 A B C D mitin

输出: 是 没有 是的

0 个答案:

没有答案