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;
- if (abs(s[0]-s[3])==2 and abs(int(s[1]-s[4]))==1 or abs(s[0]-s[3])==1 and abs(int(s[1]-s[4])==2)) cout << "YES";
- else if (s.size()!=5 or s[0]<'A' or s[0]>'H' or s[1]<'1' or s[1]>'8' or s[2]!='-'
- or s[3]<'A' or s[3]>'H' or s[4]<'1' or s[4]>'8') cout << "ERROR";
- else cout << "NO";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement