Advertisement
Stann

ShipDamage

Mar 12th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ShipDamage
  8. {
  9.     class ShipDamage
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int shipX1 = int.Parse(Console.ReadLine());
  14.             int shipY1 = int.Parse(Console.ReadLine());
  15.             int shipX2 = int.Parse(Console.ReadLine());
  16.             int shipY2 = int.Parse(Console.ReadLine());
  17.             int horizon = int.Parse(Console.ReadLine());
  18.             int catOneX = int.Parse(Console.ReadLine());
  19.             int catOneY = int.Parse(Console.ReadLine());
  20.             int catTwoX = int.Parse(Console.ReadLine());
  21.             int catTwoY = int.Parse(Console.ReadLine());
  22.             int catThreeX = int.Parse(Console.ReadLine());
  23.             int catThreeY = int.Parse(Console.ReadLine());
  24.  
  25.             int damage = 0;
  26.             int result = 0;
  27.  
  28.             int catOneAttackX = catOneX;
  29.             int catOneAttackY = (horizon - catOneY) + horizon;
  30.             int catTwoAttackX = catTwoX;
  31.             int catTwoAttackY = (horizon - catTwoY) + horizon;
  32.             int catThreeAttackX = catThreeX;
  33.             int catThreeAttackY = (horizon - catThreeY) + horizon;
  34.  
  35.             if (shipX1 < shipX2 && shipY1 > shipY2)
  36.             {
  37.                 int cornerOneX = shipX1;
  38.                 int cornerOneY = shipY2;
  39.                 int cornerTwoX = shipX2;
  40.                 int cornerTwoY = shipY1;
  41.                 // Catapult one
  42.                 //Internal body of the ship
  43.                 if (catOneAttackX > shipX1 && catOneAttackX < shipX2 && catOneAttackY < shipY1 && catOneAttackY > shipY2)
  44.                 {
  45.                     damage = 100;
  46.                     result = result + damage;
  47.                 }
  48.                 //Any of ship's sides
  49.                 if (((catOneAttackX > shipX1 && catOneAttackX < shipX2) && (catOneAttackY == shipY1 ^ catOneAttackY == shipY2)) ^
  50.                     ((catOneAttackY < shipY1 && catOneAttackY > shipY2) && (catOneAttackX == shipX1 ^ catOneAttackX == shipX2)))
  51.                 {
  52.                     damage = 50;
  53.                     result = result + damage;
  54.                 }
  55.                 //Any of ship's corners
  56.                 if ((catOneAttackX == shipX1 && catOneAttackY == shipY1) ^ (catOneAttackX == cornerOneX && catOneAttackY == cornerOneY)
  57.                     ^ (catOneAttackX == shipX2 && catOneAttackY == shipY2) ^ (catOneAttackX == cornerTwoX && catOneAttackY == cornerTwoY))
  58.                 {
  59.                     damage = 25;
  60.                     result = result + damage;
  61.                 }
  62.                 //Catapult two
  63.                 //Internal body of the ship
  64.                 if (catTwoAttackX > shipX1 && catTwoAttackX < shipX2 && catTwoAttackY < shipY1 && catTwoAttackY > shipY2)
  65.                 {
  66.                     damage = 100;
  67.                     result = result + damage;
  68.                 }
  69.                 //Any of ship's sides
  70.                 if (((catTwoAttackX > shipX1 && catTwoAttackX < shipX2) && (catTwoAttackY == shipY1 ^ catTwoAttackY == shipY2)) ^
  71.                     ((catTwoAttackY < shipY1 && catTwoAttackY > shipY2) && (catTwoAttackX == shipX1 ^ catTwoAttackX == shipX2)))
  72.                 {
  73.                     damage = 50;
  74.                     result = result + damage;
  75.                 }
  76.                 //Any of ship's corners
  77.                 if ((catTwoAttackX == shipX1 && catTwoAttackY == shipY1) ^ (catTwoAttackX == cornerOneX && catTwoAttackY == cornerOneY)
  78.                     ^ (catTwoAttackX == shipX2 && catTwoAttackY == shipY2) ^ (catTwoAttackX == cornerTwoX && catTwoAttackY == cornerTwoY))
  79.                 {
  80.                     damage = 25;
  81.                     result = result + damage;
  82.                 }
  83.                 //Catapult three
  84.                 //Internal body of the ship
  85.                 if (catThreeAttackX > shipX1 && catThreeAttackX < shipX2 && catThreeAttackY < shipY1 && catThreeAttackY > shipY2)
  86.                 {
  87.                     damage = 100;
  88.                     result = result + damage;
  89.                 }
  90.                 //Any of ship's sides
  91.                 if (((catThreeAttackX > shipX1 && catThreeAttackX < shipX2) && (catThreeAttackY == shipY1 ^ catThreeAttackY == shipY2)) ^
  92.                     ((catThreeAttackY < shipY1 && catThreeAttackY > shipY2) && (catThreeAttackX == shipX1 ^ catThreeAttackX == shipX2)))
  93.                 {
  94.                     damage = 50;
  95.                     result = result + damage;
  96.                 }
  97.                 //Any of ship's corners
  98.                 if ((catThreeAttackX == shipX1 && catThreeAttackY == shipY1) ^ (catThreeAttackX == cornerOneX && catThreeAttackY == cornerOneY)
  99.                     ^ (catThreeAttackX == shipX2 && catThreeAttackY == shipY2) ^ (catThreeAttackX == cornerTwoX && catThreeAttackY == cornerTwoY))
  100.                 {
  101.                     damage = 25;
  102.                     result = result + damage;
  103.                 }
  104.                 Console.WriteLine("{0}" + "%", result);
  105.             }
  106.             else
  107.             {
  108.                 int cornerOneX = shipX2;
  109.                 int cornerOneY = shipY1;
  110.                 int cornerTwoX = shipX1;
  111.                 int cornerTwoY = shipY2;
  112.                 //Catapult one
  113.                 //Internal body of the ship
  114.                 if (catOneAttackX > shipX2 && catOneAttackX < shipX1 && catOneAttackY < shipY1 && catOneAttackY > shipY2)
  115.                 {
  116.                     damage = 100;
  117.                     result = result + damage;
  118.                 }
  119.                 //Any of ship's sides
  120.                 if (((catOneAttackX > shipX2 && catOneAttackX < shipX1) && (catOneAttackY == shipY1 ^ catOneAttackY == shipY2)) ^
  121.                     ((catOneAttackY < shipY1 && catOneAttackY > shipY2) && (catOneAttackX == shipX1 ^ catOneAttackX == shipX2)))
  122.                 {
  123.                     damage = 50;
  124.                     result = result + damage;
  125.                 }
  126.                 //Any of ship's corners
  127.                 if ((catOneAttackX == shipX1 && catOneAttackY == shipY1) ^ (catOneAttackX == cornerOneX && catOneAttackY == cornerOneY)
  128.                     ^ (catOneAttackX == shipX2 && catOneAttackY == shipY2) ^ (catOneAttackX == cornerTwoX && catOneAttackY == cornerTwoY))
  129.                 {
  130.                     damage = 25;
  131.                     result = result + damage;
  132.                 }
  133.                 //Catapult two
  134.                 //Internal body of the ship
  135.                 if (catTwoAttackX > shipX2 && catTwoAttackX < shipX1 && catTwoAttackY < shipY1 && catTwoAttackY > shipY2)
  136.                 {
  137.                     damage = 100;
  138.                     result = result + damage;
  139.                 }
  140.                 //Any of ship's sides
  141.                 if (((catTwoAttackX > shipX2 && catTwoAttackX < shipX1) && (catTwoAttackY == shipY1 ^ catTwoAttackY == shipY2)) ^
  142.                     ((catTwoAttackY < shipY1 && catTwoAttackY > shipY2) && (catTwoAttackX == shipX1 ^ catTwoAttackX == shipX2)))
  143.                 {
  144.                     damage = 50;
  145.                     result = result + damage;
  146.                 }
  147.                 //Any of ship's corners
  148.                 if ((catTwoAttackX == shipX1 && catTwoAttackY == shipY1) ^ (catTwoAttackX == cornerOneX && catTwoAttackY == cornerOneY)
  149.                     ^ (catTwoAttackX == shipX2 && catTwoAttackY == shipY2) ^ (catTwoAttackX == cornerTwoX && catTwoAttackY == cornerTwoY))
  150.                 {
  151.                     damage = 25;
  152.                     result = result + damage;
  153.                 }
  154.                 //Catapult three
  155.                 //Internal body of the ship
  156.                 if (catThreeAttackX > shipX2 && catThreeAttackX < shipX1 && catThreeAttackY < shipY1 && catThreeAttackY > shipY2)
  157.                 {
  158.                     damage = 100;
  159.                     result = result + damage;
  160.                 }
  161.                 //Any of ship's sides
  162.                 if (((catThreeAttackX > shipX2 && catThreeAttackX < shipX1) && (catThreeAttackY == shipY1 ^ catThreeAttackY == shipY2)) ^
  163.                    ((catThreeAttackY < shipY1 && catThreeAttackY > shipY2) && (catThreeAttackX == shipX1 ^ catThreeAttackX == shipX2)))
  164.                 {
  165.                     damage = 50;
  166.                     result = result + damage;
  167.                 }
  168.                 //Any of ship's corners
  169.                 if ((catThreeAttackX == shipX1 && catThreeAttackY == shipY1) ^ (catThreeAttackX == cornerOneX && catThreeAttackY == cornerOneY)
  170.                    ^ (catThreeAttackX == shipX2 && catThreeAttackY == shipY2) ^ (catThreeAttackX == cornerTwoX && catThreeAttackY == cornerTwoY))
  171.                 {
  172.                     damage = 25;
  173.                     result = result + damage;
  174.                 }
  175.                 Console.WriteLine("{0}" + "%", result);
  176.             }
  177.         }
  178.     }
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement