Advertisement
Zuneve

efg1111

Oct 14th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. using namespace std;
  5. int main() {
  6. string s;
  7. cin >> s;
  8. char a,b;
  9. a=s[0];
  10. b=s[3];
  11. int a1=int(a)-64, b1=int(b)-64;
  12. if (abs(a1-b1)==2 and abs(int(s[1]-s[4]))==1 or abs(a1-b1)==1 and abs(int(s[1]-s[4])==2)) cout << "YES";
  13. else if (s.size()<5 or isalpha(s[0])== false or s[2]!='-' or isdigit(s[1])==false or isalpha(s[3])==false or
  14. isdigit(s[4])==false) cout << "ERROR";
  15. else cout << "NO";
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement