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

浙公网安备 33010602011771号