Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. /**
  2. *
  3. * Solution to homework task
  4. * Introduction to programming course
  5. * Faculty of Mathematics and Informatics of Sofia University
  6. * Winter semester 2016/2017
  7. *
  8. * @author Nikolay Naydenov
  9. * @idnumber 81565
  10. * @task 4
  11. * @compiler GCC
  12. *
  13. */
  14.  
  15. #include <iostream>
  16. #include <cmath>
  17.  
  18. using namespace std;
  19.  
  20. int main () {
  21. char piece,
  22. ax,
  23. ay,
  24. dx,
  25. dy;
  26. bool isCheck = false;
  27.  
  28. cin >> piece;
  29. cin >> ax >> ay;
  30. cin >> dx >> dy;
  31.  
  32. switch(piece) {
  33. case 'Q':
  34. isCheck = ax == dx || ay == dy || abs(ax - dx) == abs(ay - dy);
  35. break;
  36.  
  37.  
  38.  
  39. case 'B':
  40. isCheck = abs(ax - dx) == abs(ay - dy);
  41. break;
  42.  
  43. case 'N':
  44. isCheck =
  45. abs(ax - dx) == 1 && abs(ay - dy) == 2 ||
  46. abs(ax - dx) == 2 && abs(ay - dy) == 1;
  47. break;
  48.  
  49. case 'R':
  50. isCheck = ax == dx || ay == dy;
  51. break;
  52. }
  53.  
  54. cout << (isCheck ? "Yes" : "No");
  55. cout << '\n';
  56.  
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement