Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <algorithm>
- using namespace std;
- int main() {
- string s;
- cin >> s;
- char a,b;
- a=s[0];
- b=s[3];
- int a1=int(a)-64, b1=int(b)-64;
- 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";
- else if (s.size()<5 or isalpha(s[0])== false or s[2]!='-' or isdigit(s[1])==false or isalpha(s[3])==false or
- isdigit(s[4])==false) cout << "ERROR";
- else cout << "NO";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement