Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int shipX1 = int.Parse(Console.ReadLine());
- int shipY1 = int.Parse(Console.ReadLine());
- int shipX2 = int.Parse(Console.ReadLine());
- int shipY2 = int.Parse(Console.ReadLine());
- int horizont = int.Parse(Console.ReadLine());
- int damages = 0;
- for (int i = 0; i < 3; i++)
- {
- int catapultX = int.Parse(Console.ReadLine());
- int catapultY = int.Parse(Console.ReadLine());
- catapultY = horizont - catapultY;
- if (i == 0)
- {
- shipY1 = shipY1 - horizont;
- shipY2 = shipY2 - horizont;
- }
- if (catapultX > shipX1 && catapultX < shipX2 && catapultY > shipY1 && catapultY < shipY2)
- {
- //inside the ship = 100%
- damages = damages + 100;
- }
- else if (catapultX < shipX1 && catapultX > shipX2 && catapultY < shipY1 && catapultY > shipY2)
- {
- //inside the ship = 100%
- damages = damages + 100;
- }
- else if (catapultX > shipX1 && catapultX < shipX2 && catapultY < shipY1 && catapultY > shipY2)
- {
- //inside the ship = 100%
- damages = damages + 100;
- }
- else if (catapultX < shipX1 && catapultX > shipX2 && catapultY < shipY1 && catapultY > shipY2)
- {
- //inside the ship = 100%
- damages = damages + 100;
- }
- else if ((catapultX == shipX1 || catapultX == shipX2) && (catapultY > shipY1 && catapultY < shipY2))
- {
- //X sides of the ship = 50%
- damages = damages + 50;
- }
- else if ((catapultX == shipX1 || catapultX == shipX2) && (catapultY < shipY1 && catapultY > shipY2))
- {
- //X sides of the ship = 50%
- damages = damages + 50;
- }
- else if ((catapultY == shipY1 || catapultY == shipY2) && (catapultX > shipX1 && catapultX < shipX2))
- {
- //Y sides of the ship = 50%
- damages = damages + 50;
- }
- else if ((catapultY == shipY1 || catapultY == shipY2) && (catapultX < shipX1 && catapultX > shipX2))
- {
- //Y sides of the ship = 50%
- damages = damages + 50;
- }
- else if ((catapultX == shipX1 && catapultY == shipY1) || (catapultX == shipX2 && catapultY == shipY2))
- {
- //hit the corner = 25 %
- damages = damages + 25;
- }
- else if ((catapultX == shipX1 && catapultY == shipY2) || (catapultX == shipX2 && catapultY == shipY1))
- {
- //hit the corner = 25 %
- damages = damages + 25;
- }
- }
- Console.WriteLine(damages + "%");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement