📄 words_palin_1.cpp
字号:
/*
* Description:
*
* Examine whether a string is a palindrome.
*
* History:
*
* Initial version created by Royal, Mar. 2004.
*
* Notes:
*
* This code has been written to conform to standard C++ and STL. It has been
* compiled successfully using GNU C++ 3.2, Borland C++ 5.5, and Visual C++ 7.0.
*/
#include <iostream>
#include <string>
using namespace std;
bool is_palindrome(const string& s)
{
for (string::size_type i = 0; i != s.size(); ++i)
if (s[i] != s[s.size() - 1 - i]) return false;
return true;
}
int main()
{
string s;
while (cin >> s)
{
if (is_palindrome(s)) cout << "\"" << s << "\"" << " is a palindrome" << endl;
else cout << "\""<< s << "\"" << " is not a palindrome" << endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -