Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ShipDamage
- {
- class ShipDamage
- {
- static void Main(string[] args)
- {
- 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 horizon = int.Parse(Console.ReadLine());
- int catOneX = int.Parse(Console.ReadLine());
- int catOneY = int.Parse(Console.ReadLine());
- int catTwoX = int.Parse(Console.ReadLine());
- int catTwoY = int.Parse(Console.ReadLine());
- int catThreeX = int.Parse(Console.ReadLine());
- int catThreeY = int.Parse(Console.ReadLine());
- int damage = 0;
- int result = 0;
- int catOneAttackX = catOneX;
- int catOneAttackY = (horizon - catOneY) + horizon;
- int catTwoAttackX = catTwoX;
- int catTwoAttackY = (horizon - catTwoY) + horizon;
- int catThreeAttackX = catThreeX;
- int catThreeAttackY = (horizon - catThreeY) + horizon;
- if (shipX1 < shipX2 && shipY1 > shipY2)
- {
- int cornerOneX = shipX1;
- int cornerOneY = shipY2;
- int cornerTwoX = shipX2;
- int cornerTwoY = shipY1;
- // Catapult one
- //Internal body of the ship
- if (catOneAttackX > shipX1 && catOneAttackX < shipX2 && catOneAttackY < shipY1 && catOneAttackY > shipY2)
- {
- damage = 100;
- result = result + damage;
- }
- //Any of ship's sides
- if (((catOneAttackX > shipX1 && catOneAttackX < shipX2) && (catOneAttackY == shipY1 ^ catOneAttackY == shipY2)) ^
- ((catOneAttackY < shipY1 && catOneAttackY > shipY2) && (catOneAttackX == shipX1 ^ catOneAttackX == shipX2)))
- {
- damage = 50;
- result = result + damage;
- }
- //Any of ship's corners
- if ((catOneAttackX == shipX1 && catOneAttackY == shipY1) ^ (catOneAttackX == cornerOneX && catOneAttackY == cornerOneY)
- ^ (catOneAttackX == shipX2 && catOneAttackY == shipY2) ^ (catOneAttackX == cornerTwoX && catOneAttackY == cornerTwoY))
- {
- damage = 25;
- result = result + damage;
- }
- //Catapult two
- //Internal body of the ship
- if (catTwoAttackX > shipX1 && catTwoAttackX < shipX2 && catTwoAttackY < shipY1 && catTwoAttackY > shipY2)
- {
- damage = 100;
- result = result + damage;
- }
- //Any of ship's sides
- if (((catTwoAttackX > shipX1 && catTwoAttackX < shipX2) && (catTwoAttackY == shipY1 ^ catTwoAttackY == shipY2)) ^
- ((catTwoAttackY < shipY1 && catTwoAttackY > shipY2) && (catTwoAttackX == shipX1 ^ catTwoAttackX == shipX2)))
- {
- damage = 50;
- result = result + damage;
- }
- //Any of ship's corners
- if ((catTwoAttackX == shipX1 && catTwoAttackY == shipY1) ^ (catTwoAttackX == cornerOneX && catTwoAttackY == cornerOneY)
- ^ (catTwoAttackX == shipX2 && catTwoAttackY == shipY2) ^ (catTwoAttackX == cornerTwoX && catTwoAttackY == cornerTwoY))
- {
- damage = 25;
- result = result + damage;
- }
- //Catapult three
- //Internal body of the ship
- if (catThreeAttackX > shipX1 && catThreeAttackX < shipX2 && catThreeAttackY < shipY1 && catThreeAttackY > shipY2)
- {
- damage = 100;
- result = result + damage;
- }
- //Any of ship's sides
- if (((catThreeAttackX > shipX1 && catThreeAttackX < shipX2) && (catThreeAttackY == shipY1 ^ catThreeAttackY == shipY2)) ^
- ((catThreeAttackY < shipY1 && catThreeAttackY > shipY2) && (catThreeAttackX == shipX1 ^ catThreeAttackX == shipX2)))
- {
- damage = 50;
- result = result + damage;
- }
- //Any of ship's corners
- if ((catThreeAttackX == shipX1 && catThreeAttackY == shipY1) ^ (catThreeAttackX == cornerOneX && catThreeAttackY == cornerOneY)
- ^ (catThreeAttackX == shipX2 && catThreeAttackY == shipY2) ^ (catThreeAttackX == cornerTwoX && catThreeAttackY == cornerTwoY))
- {
- damage = 25;
- result = result + damage;
- }
- Console.WriteLine("{0}" + "%", result);
- }
- else
- {
- int cornerOneX = shipX2;
- int cornerOneY = shipY1;
- int cornerTwoX = shipX1;
- int cornerTwoY = shipY2;
- //Catapult one
- //Internal body of the ship
- if (catOneAttackX > shipX2 && catOneAttackX < shipX1 && catOneAttackY < shipY1 && catOneAttackY > shipY2)
- {
- damage = 100;
- result = result + damage;
- }
- //Any of ship's sides
- if (((catOneAttackX > shipX2 && catOneAttackX < shipX1) && (catOneAttackY == shipY1 ^ catOneAttackY == shipY2)) ^
- ((catOneAttackY < shipY1 && catOneAttackY > shipY2) && (catOneAttackX == shipX1 ^ catOneAttackX == shipX2)))
- {
- damage = 50;
- result = result + damage;
- }
- //Any of ship's corners
- if ((catOneAttackX == shipX1 && catOneAttackY == shipY1) ^ (catOneAttackX == cornerOneX && catOneAttackY == cornerOneY)
- ^ (catOneAttackX == shipX2 && catOneAttackY == shipY2) ^ (catOneAttackX == cornerTwoX && catOneAttackY == cornerTwoY))
- {
- damage = 25;
- result = result + damage;
- }
- //Catapult two
- //Internal body of the ship
- if (catTwoAttackX > shipX2 && catTwoAttackX < shipX1 && catTwoAttackY < shipY1 && catTwoAttackY > shipY2)
- {
- damage = 100;
- result = result + damage;
- }
- //Any of ship's sides
- if (((catTwoAttackX > shipX2 && catTwoAttackX < shipX1) && (catTwoAttackY == shipY1 ^ catTwoAttackY == shipY2)) ^
- ((catTwoAttackY < shipY1 && catTwoAttackY > shipY2) && (catTwoAttackX == shipX1 ^ catTwoAttackX == shipX2)))
- {
- damage = 50;
- result = result + damage;
- }
- //Any of ship's corners
- if ((catTwoAttackX == shipX1 && catTwoAttackY == shipY1) ^ (catTwoAttackX == cornerOneX && catTwoAttackY == cornerOneY)
- ^ (catTwoAttackX == shipX2 && catTwoAttackY == shipY2) ^ (catTwoAttackX == cornerTwoX && catTwoAttackY == cornerTwoY))
- {
- damage = 25;
- result = result + damage;
- }
- //Catapult three
- //Internal body of the ship
- if (catThreeAttackX > shipX2 && catThreeAttackX < shipX1 && catThreeAttackY < shipY1 && catThreeAttackY > shipY2)
- {
- damage = 100;
- result = result + damage;
- }
- //Any of ship's sides
- if (((catThreeAttackX > shipX2 && catThreeAttackX < shipX1) && (catThreeAttackY == shipY1 ^ catThreeAttackY == shipY2)) ^
- ((catThreeAttackY < shipY1 && catThreeAttackY > shipY2) && (catThreeAttackX == shipX1 ^ catThreeAttackX == shipX2)))
- {
- damage = 50;
- result = result + damage;
- }
- //Any of ship's corners
- if ((catThreeAttackX == shipX1 && catThreeAttackY == shipY1) ^ (catThreeAttackX == cornerOneX && catThreeAttackY == cornerOneY)
- ^ (catThreeAttackX == shipX2 && catThreeAttackY == shipY2) ^ (catThreeAttackX == cornerTwoX && catThreeAttackY == cornerTwoY))
- {
- damage = 25;
- result = result + damage;
- }
- Console.WriteLine("{0}" + "%", result);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement