#include<iostream>
#include<ctype.h>
#include<algorithm>
#include<string>
using namespace std;
int main(){
str_testing.erase(
remove_if(str_testing.begin(),str_testing.end(),static_cast<int(*)(int)>(&ispunct)),
str_testing.end());
str_testing.erase(
remove_if(str_testing.begin(),str_testing.end(),static_cast<int(*)(int)>(&isspace)),
str_testing.end());
string s;
cout<<"Please input a string:"<<endl;
cin>>s;
int len = strlen(s);int is_palindrome = 1;
for(j = 0;j<len;i++){
s[i]=tolower(s[i])}
for(int i = 0;i<len/2;i++){
if(s[i]!=s[len-1-i]){
is_palindrome=0;
break}
}
if(is_palindrome){
cout<<"The string is a palindrome"<<endl;}
else{
cout<<"The string is not a palindrome"<<endl;}
return 0;
}
第二次上机作业三
最新推荐文章于 2021-05-17 00:49:33 发布