判断是否为回文

    判断用户输入的字符串是否为回文。回文是指正反拼写形式都是一样的词,譬如“racecar”。
    使用字符串翻转的方法~~~soeasy~~!!
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. using namespace std;
  5. int main(int argc, char const *argv[])
  6. {
  7. string s,t;
  8. cin>>s;
  9. t=s;
  10. reverse(s.begin(),s.end());
  11. if(s == t)
  12. cout<<"是翻转字符串"<<endl;
  13. else
  14. cout<<"不是翻转字符串"<<endl;
  15. return 0;
  16. }





原文地址:https://www.cnblogs.com/clifff/p/5039013.html