Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int castleX, castleY, queenX, queenY;
  9.  
  10. do
  11. {
  12. cout << "enter the Knight X and Knight Y\n";
  13. cin >> castleX >> castleY;
  14. cout << endl;
  15. } while (castleX>8 || castleX<=0 || castleY>8 || castleY<=0);
  16.  
  17. do
  18. {
  19. cout << "enter the Queen X and Queen Y\n";
  20. cin >> queenX >> queenY;
  21. cout << endl;
  22. } while (queenX > 8 || queenX <= 0 || queenY > 8 || queenY <= 0);
  23.  
  24. cout << "the Castle" << castleX << ";" << castleY << ")\n";
  25. cout << "the Queen (" << queenX << ";" << queenY << ")\n";
  26. cout << endl;
  27.  
  28. if (castleX == queenX || castleY == queenY)
  29. cout << "the Castle bites the Queen\n";
  30. else
  31. cout << "the Castle doesn't bites the Queen\n";
  32.  
  33. if(castleX == queenX || castleY == queenY || castleX - castleY ==queenX - queenY)
  34. cout << "the Queen bites the Castle\n";
  35. else
  36. cout << "the Queen doesn't bites the Castle\n";
  37.  
  38. cout << endl;
  39.  
  40. if (castleX + 1 == queenX || castleX - 1 == queenX || castleY + 1 == queenY || castleY - 1 == queenY)
  41. cout << "the Castle bites the Queen in one move\n";
  42. else
  43. cout << "the Castle doesn't bites the Queen in one move\n";
  44.  
  45. if (castleX + 1 == queenX || castleX - 1 == queenX || castleY + 1 == queenY || castleY - 1 == queenY ||
  46. castleX - castleY +1 == queenX - queenY || castleX - castleY - 1 == queenX - queenY)
  47. cout << "the Queen bites the Castle in one move\n";
  48. else
  49. cout << "the Queen doesn't bites the Castle in one move\n";
  50.  
  51. cout << endl;
  52.  
  53. system("pause");
  54.  
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement