迴圈

輸入字串

判別是否對稱

回文

不是

不是回文

 

 

 

 

#include <iostream>

using namespace std;

int main()
{
    string str;
    bool bLoop;

    while(cin >> str)
    {
        bLoop = true;
        for(int i = 0, j = str.length()-1; i<=j; i++, j--)
            if(str[i] != str[j])
            {
                bLoop = false;
                break;
            }

        bLoop? cout << "yes\n": cout << "no\n";
    }

    return 0;
}

arrow
arrow
    全站熱搜

    大神(偽) 發表在 痞客邦 留言(0) 人氣()