AcWing 5882. 字母串
原题链接
简单
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
string s;
int main() {
for (cin >> s; cin >> s; ) {
bool t = true;
for (int i = 0; i < s.size() - 1; i++) {
if ((s[i] >= 'A' && s[i] <= 'Z') && (s[i + 1] == char(s[i] + ' ') || (s[i] != 'Z' && s[i + 1] == char(s[i] + 1)))) continue;
if ((s[i] >= 'a' && s[i] <= 'z') && (s[i + 1] == char(s[i] - ' ') || (s[i] != 'a' && s[i + 1] == char(s[i] - 1)))) continue;
t = false; break;
}
puts(t ? "Y" : "N");
}
return 0;
}