Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * Solution to homework task
- * Introduction to programming course
- * Faculty of Mathematics and Informatics of Sofia University
- * Winter semester 2016/2017
- *
- * @author Nikolay Naydenov
- * @idnumber 81565
- * @task 4
- * @compiler GCC
- *
- */
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main () {
- char piece,
- ax,
- ay,
- dx,
- dy;
- bool isCheck = false;
- cin >> piece;
- cin >> ax >> ay;
- cin >> dx >> dy;
- switch(piece) {
- case 'Q':
- isCheck = ax == dx || ay == dy || abs(ax - dx) == abs(ay - dy);
- break;
- case 'B':
- isCheck = abs(ax - dx) == abs(ay - dy);
- break;
- case 'N':
- isCheck =
- abs(ax - dx) == 1 && abs(ay - dy) == 2 ||
- abs(ax - dx) == 2 && abs(ay - dy) == 1;
- break;
- case 'R':
- isCheck = ax == dx || ay == dy;
- break;
- }
- cout << (isCheck ? "Yes" : "No");
- cout << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement