ellapt

ShipDamage

Dec 4th, 2012
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. using System;
  2.  
  3. class ShipDamage
  4. {
  5. static void Main()
  6. {
  7. int boat1X = int.Parse(Console.ReadLine());
  8. int boat1Y = int.Parse(Console.ReadLine());
  9. int boat2X = int.Parse(Console.ReadLine());
  10. int boat2Y = int.Parse(Console.ReadLine());
  11.  
  12. int horizon = int.Parse(Console.ReadLine());
  13.  
  14. int c1X = int.Parse(Console.ReadLine());
  15. int c1Y = int.Parse(Console.ReadLine());
  16. int c2X = int.Parse(Console.ReadLine());
  17. int c2Y = int.Parse(Console.ReadLine());
  18. int c3X = int.Parse(Console.ReadLine());
  19. int c3Y = int.Parse(Console.ReadLine());
  20.  
  21. boat1Y-= horizon;
  22. boat2Y-= horizon;
  23. c1Y -= horizon;
  24. c2Y -= horizon;
  25. c3Y -= horizon;
  26.  
  27. int projC1Y = -c1Y;
  28. int projC2Y = -c2Y;
  29. int projC3Y = -c3Y;
  30.  
  31. int top = Math.Max(boat1Y, boat2Y);
  32. int left = Math.Min(boat1X, boat2X);
  33. int bottom = Math.Min(boat1Y, boat2Y);
  34. int right = Math.Max(boat1X, boat2X);
  35.  
  36. int sum = 0;
  37.  
  38. if (projC1Y > bottom && projC1Y < top)
  39. {
  40. if (c1X > left && c1X < right)
  41. {
  42. sum += 100;
  43. }
  44. else if (c1X == left || c1X == right)
  45. {
  46. sum += 50;
  47. }
  48. }
  49. else if (projC1Y == bottom || projC1Y == top)
  50. {
  51. if (c1X > left && c1X < right)
  52. {
  53. sum += 50;
  54. }
  55. else if (c1X == left || c1X == right)
  56. {
  57. sum += 25;
  58. }
  59. }
  60. if (projC2Y > bottom && projC2Y < top)
  61. {
  62. if (c2X > left && c2X < right)
  63. {
  64. sum += 100;
  65. }
  66. else if (c2X == left || c2X == right)
  67. {
  68. sum += 50;
  69. }
  70. }
  71. else if (projC2Y == bottom || projC2Y == top)
  72. {
  73. if (c2X > left && c2X < right)
  74. {
  75. sum += 50;
  76. }
  77. else if (c2X == left || c2X == right)
  78. {
  79. sum += 25;
  80. }
  81. }
  82. if (projC3Y > bottom && projC3Y < top)
  83. {
  84. if (c3X > left && c3X < right)
  85. {
  86. sum += 100;
  87. }
  88. else if (c3X == left || c3X == right)
  89. {
  90. sum += 50;
  91. }
  92. }
  93. else if (projC3Y == bottom || projC3Y == top)
  94. {
  95. if (c3X > left && c3X < right)
  96. {
  97. sum += 50;
  98. }
  99. else if (c3X == left || c3X == right)
  100. {
  101. sum += 25;
  102. }
  103. }
  104. Console.WriteLine(sum + "%");
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment