#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;
}
第二次上机作业三
最新推荐文章于 2025-10-09 16:41:39 发布
本文介绍了一个C++程序,用于检查用户输入的字符串是否为回文。程序首先移除字符串中的所有标点符号和空格,并将所有字符转换为小写以进行大小写不敏感的比较。然后通过对比字符串首尾字符的方式判断该字符串是否为回文。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
ACE-Step
音乐合成
ACE-Step
ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言
3726

被折叠的 条评论
为什么被折叠?



