Advertisement
petromaxa

Untitled

Dec 11th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace _1.Problem_ShipDamage
  7. {
  8. class Program
  9. {
  10. static void Main()
  11. {
  12. int Sx1 = int.Parse(Console.ReadLine());
  13. int Sy1 = int.Parse(Console.ReadLine());
  14. int Sx2 = int.Parse(Console.ReadLine());
  15. int Sy2 = int.Parse(Console.ReadLine());
  16. int H = int.Parse(Console.ReadLine());
  17. int Cx1 = int.Parse(Console.ReadLine());
  18. int Cy1 = int.Parse(Console.ReadLine());
  19. int Cx2 = int.Parse(Console.ReadLine());
  20. int Cy2 = int.Parse(Console.ReadLine());
  21. int Cx3 = int.Parse(Console.ReadLine());
  22. int Cy3 = int.Parse(Console.ReadLine());
  23.  
  24. int newCy1 = H + (H - Cy1);
  25. int newCy2 = H + (H - Cy2);
  26. int newCy3 = H + (H - Cy3);
  27. double damage = 0;
  28.  
  29. //Corners hit
  30. if ((Cx1==Sx1 && newCy1==Sy1)||(Cx1==Sx2 && newCy1==Sy2)||(Cx1==Sx1 && newCy1==Sy2)||(Cx1==Sx2 && newCy1==Sy1))
  31. {
  32. damage=damage+0.25;
  33. }
  34. if ((Cx2==Sx1 && newCy2==Sy1)||(Cx2==Sx2 && newCy2==Sy2)||(Cx2==Sx1 && newCy2==Sy2)||(Cx2==Sx2 && newCy2==Sy1))
  35. {
  36. damage=damage+0.25;
  37. }
  38. if ((Cx3==Sx1 && newCy3==Sy1)||(Cx3==Sx2 && newCy3==Sy2)||(Cx3==Sx1 && newCy3==Sy2)||(Cx3==Sx2 && newCy3==Sy1))
  39. {
  40. damage=damage+0.25;
  41. }
  42.  
  43. //Sides hit
  44. if ((Cx1==Sx1 && newCy1 < Math.Max(Sy1, Sy2) && newCy1 > Math.Min(Sy1, Sy2))||
  45. (Cx1==Sx2 && newCy1 < Math.Max(Sy1, Sy2) && newCy1 > Math.Min(Sy1, Sy2))||
  46. (newCy1==Sy1 && Cx1 < Math.Max(Sx1, Sx2) && Cx1 > Math.Min(Sx1, Sx2))||
  47. (newCy1==Sy2 && Cx1 < Math.Max(Sx1, Sx2) && Cx1 > Math.Min(Sx1, Sx2)))
  48. {
  49. damage=damage+0.5;
  50. }
  51. if ((Cx2==Sx1 && newCy2 < Math.Max(Sy1, Sy2) && newCy2 > Math.Min(Sy1, Sy2))||
  52. (Cx2==Sx2 && newCy2 < Math.Max(Sy1, Sy2) && newCy2 > Math.Min(Sy1, Sy2))||
  53. (newCy2==Sy1 && Cx2 < Math.Max(Sx1, Sx2) && Cx2 > Math.Min(Sx1, Sx2))||
  54. (newCy2==Sy2 && Cx2 < Math.Max(Sx1, Sx2) && Cx2 > Math.Min(Sx1, Sx2)))
  55. {
  56. damage=damage+0.5;
  57. }
  58. if ((Cx3==Sx1 && newCy3 < Math.Max(Sy1, Sy2) && newCy3 > Math.Min(Sy1, Sy2))||
  59. (Cx3==Sx2 && newCy3 < Math.Max(Sy1, Sy2) && newCy3 > Math.Min(Sy1, Sy2))||
  60. (newCy3==Sy1 && Cx3 < Math.Max(Sx1, Sx2) && Cx3 > Math.Min(Sx1, Sx2))||
  61. (newCy3==Sy2 && Cx3 < Math.Max(Sx1, Sx2) && Cx3 > Math.Min(Sx1, Sx2)))
  62. {
  63. damage=damage+0.5;
  64. }
  65.  
  66. //Body hit
  67. if ((Cx1 < Math.Max(Sx1, Sx2) && Cx1 > Math.Min(Sx1, Sx2) && newCy1 < Math.Max(Sy1, Sy2) && newCy1 > Math.Min(Sy1, Sy2)))
  68. {
  69. damage=damage+1;
  70. }
  71. if ((Cx2 < Math.Max(Sx1, Sx2) && Cx2 > Math.Min(Sx1, Sx2) && newCy2 < Math.Max(Sy1, Sy2) && newCy2 > Math.Min(Sy1, Sy2)))
  72. {
  73. damage=damage+1;
  74. }
  75. if ((Cx3 < Math.Max(Sx1, Sx2) && Cx3 > Math.Min(Sx1, Sx2) && newCy3 < Math.Max(Sy1, Sy2) && newCy3 > Math.Min(Sy1, Sy2)))
  76. {
  77. damage=damage+1;
  78. }
  79. Console.WriteLine("{0:0%}",damage);
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement