tijie
2025-05-01 12:26:49
发布于:四川
1阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
bool is_hw(string s) {
string t = "";
for (int i = s.size() - 1; i >= 0; i--)
t += s[i];
if (t == s) return true;
else return false;
}
void is_zf(string s) {
bool f1 = 0, f2 = 0;
for (int i = 0; i < s.size(); i++){
if(s[i] >= '0' && s[i] <= '9')
f2 = 1;
else f1 = 1;
}
if(f1 == 1 && f2 == 1) cout << "string" << endl;
else if(f1 == 1 && f2 == 0) cout << "letter" << endl;
else cout << "number" << endl;
}
int main(){
string a, b;
cin >> a >> b;
int n;
cin >> n;
while (n--) {
string s;
cin >> s;
string t = "";
for (int i = 0; i < s.size(); i++){
if(s[i] == 'a') t += a;
else t += b;
}
cout << t << endl;
if(is_hw(t)) cout << "palindrome ";
else cout << "non-palindrome ";
is_zf(t);
}
return 0;
}
这里空空如也
有帮助,赞一个