简单tijie
2026-09-11 15:32:26
发布于:四川
1阅读
0回复
0点赞
代码可能较长
#include<bits/stdc++.h>
using namespace std;
bool fun(string x){
string y=x;
reverse(x.begin(),x.end());
if(y==x){
return true;
}
return false;
}
void fun1(string x){
bool a=false,b=false;
for(int i=0;i<x.size();i++){
if(x[i]>='0'&&x[i]<='9'){
a=true;
}
else if(x[i]>='A'&&x[i]<='Z'||x[i]>='a'&&x[i]<='z'){
b=true;
}
}
if(a==true&&b==false){
cout<<"number"<<endl;
}
else if(a==false&&b==true){
cout<<"letter"<<endl;
}
else if(a==true&&b==true){
cout<<"string"<<endl;
}
}
int main(){
string a,b;
cin>>a>>b;
int n;
cin>>n;
for(int i=0;i<n;i++){
string s;
cin>>s;
string r;
for(int j=0;j<s.size();j++){
if(s[j]=='a'){
r+=a;
}
else if(s[j]=='b'){
r+=b;
}
}
cout<<r<<endl;
if(fun(r)){
cout<<"palindrome ";
}else{
cout<<"non-palindrome ";
}
fun1(r);
}
return 0;
}
这里空空如也








有帮助,赞一个