Advertisement
stanevplamen

01.7.3.1.CoordinateShipDamage

May 16th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.18 KB | None | 0 0
  1. using System;
  2.  
  3. class CoordinateShipDamage
  4. {
  5.     static void Main()
  6.     {
  7.  
  8.         int sx1 = int.Parse(Console.ReadLine());
  9.         int sy1 = int.Parse(Console.ReadLine());
  10.         int sx2 = int.Parse(Console.ReadLine());
  11.         int sy2 = int.Parse(Console.ReadLine());
  12.  
  13.         int h = int.Parse(Console.ReadLine());
  14.  
  15.         int cx1 = int.Parse(Console.ReadLine());
  16.         int cy1 = int.Parse(Console.ReadLine());
  17.         int cx2 = int.Parse(Console.ReadLine());
  18.         int cy2 = int.Parse(Console.ReadLine());
  19.         int cx3 = int.Parse(Console.ReadLine());
  20.         int cy3 = int.Parse(Console.ReadLine());
  21.  
  22.         int bombResult = 0;
  23.  
  24.         // ========================================= bombs coordinates
  25.         // === bomb 1
  26.         int bombC1y = 0;
  27.         int bombC1x = cx1;
  28.         if (cx1 != h)
  29.         {
  30.             bombC1y = h + h - cy1;
  31.         }
  32.         else if (cx1 == h)
  33.         {
  34.             bombC1y = cy1;
  35.         }
  36.  
  37.         //===== bomb 2
  38.  
  39.         int bombC2y = 0;
  40.         int bombC2x = cx2;
  41.         if (cx2 != h)
  42.         {
  43.             bombC2y = h + h - cy2;
  44.         }
  45.         else if (cx2 == h)
  46.         {
  47.             bombC2y = cy2;
  48.         }
  49.  
  50.         //===== bomb 2
  51.  
  52.         int bombC3y = 0;
  53.         int bombC3x = cx3;
  54.         if (cx3 != h)
  55.         {
  56.             bombC3y = h + h - cy3;
  57.         }
  58.         else if (cx3 == h)
  59.         {
  60.             bombC3y = cy3;
  61.         }
  62.  
  63.  
  64.        
  65.         // =========================================== coordinates if the rectalgular
  66.  
  67.         // sx1
  68.         // sy1
  69.         int sx1a = sx1;
  70.         int sy1a = sy2;
  71.         // sx2
  72.         // sy2
  73.         int sx2a = sx2;
  74.         int sy2a = sy1;
  75.  
  76.         // ============================================ if hitted
  77.         // bomb 1
  78.  
  79.         if (((sx1 < bombC1x && bombC1x < sx2) && (sy2 < bombC1y && bombC1y < sy1)) || ((sx1 > bombC1x && bombC1x > sx2) && (sy2 < bombC1y && bombC1y < sy1)))
  80.         {
  81.             bombResult += 100;
  82.         }
  83.         else if (((sx1 < bombC1x && bombC1x < sx2) && (sy2 > bombC1y && bombC1y > sy1)) || ((sx1 > bombC1x && bombC1x > sx2) && (sy2 > bombC1y && bombC1y > sy1)))
  84.         {
  85.             bombResult += 100;
  86.         }
  87.         else if (((sx1 == bombC1x || bombC1x == sx2) && (sy2 < bombC1y && bombC1y < sy1)) ||(sy2 > bombC1y && bombC1y > sy1))
  88.         {
  89.             bombResult += 50;
  90.         }
  91.         else if (((sx1 < bombC1x && bombC1x < sx2) && (sy2 == bombC1y || bombC1y == sy1)) || ((sx1 > bombC1x && bombC1x > sx2) && (sy2 == bombC1y || bombC1y == sy1)))
  92.         {
  93.             bombResult += 50;
  94.         }
  95.         else if ((sx1 == bombC1x && sy1 == bombC1y) || (sx2 == bombC1x && sy2 == bombC1y) || (sx1a == bombC1x && sy1a == bombC1y) || (sx2a == bombC1x && sy2a == bombC1y))
  96.         {
  97.             bombResult += 25;
  98.         }
  99.         else
  100.         {
  101.             bombResult += 0;
  102.         }
  103.         // bomb 2
  104.  
  105.         if (((sx1 < bombC2x && bombC2x < sx2) && (sy2 < bombC2y && bombC2y < sy1)) || ((sx1 > bombC2x && bombC2x > sx2) && (sy2 < bombC2y && bombC2y < sy1)))
  106.         {
  107.             bombResult += 100;
  108.         }
  109.         else if (((sx1 < bombC2x && bombC2x < sx2) && (sy2 > bombC2y && bombC2y > sy1)) || ((sx1 > bombC2x && bombC2x > sx2) && (sy2 > bombC2y && bombC2y > sy1)))
  110.         {
  111.             bombResult += 100;
  112.         }
  113.         else if (((sx1 == bombC2x || bombC2x == sx2) && (sy2 < bombC2y && bombC2y < sy1)) || (sy2 > bombC2y && bombC2y > sy1))
  114.         {
  115.             bombResult += 50;
  116.         }
  117.         else if (((sx1 < bombC2x && bombC2x < sx2) && (sy2 == bombC2y || bombC2y == sy1)) || ((sx1 > bombC2x && bombC2x > sx2) && (sy2 == bombC2y || bombC2y == sy1)))
  118.         {
  119.             bombResult += 50;
  120.         }
  121.         else if ((sx1 == bombC2x && sy1 == bombC2y) || (sx2 == bombC2x && sy2 == bombC2y) || (sx1a == bombC2x && sy1a == bombC2y) || (sx2a == bombC2x && sy2a == bombC2y))
  122.         {
  123.             bombResult += 25;
  124.         }
  125.         else
  126.         {
  127.             bombResult += 0;
  128.         }
  129.         // bomb 3
  130.  
  131.         if (((sx1 < bombC3x && bombC3x < sx2) && (sy2 < bombC3y && bombC3y < sy1)) || ((sx1 > bombC3x && bombC3x > sx2) && (sy2 < bombC3y && bombC3y < sy1)))
  132.         {
  133.             bombResult += 100;
  134.         }
  135.         else if (((sx1 < bombC3x && bombC3x < sx2) && (sy2 > bombC3y && bombC3y > sy1)) || ((sx1 > bombC3x && bombC3x > sx2) && (sy2 > bombC3y && bombC3y > sy1)))
  136.         {
  137.             bombResult += 100;
  138.         }
  139.         else if (((sx1 == bombC3x || bombC3x == sx2) && (sy2 < bombC3y && bombC3y < sy1)) || (sy2 > bombC3y && bombC3y > sy1))
  140.         {
  141.             bombResult += 50;
  142.         }
  143.         else if (((sx1 < bombC3x && bombC3x < sx2) && (sy2 == bombC3y || bombC3y == sy1)) || ((sx1 > bombC3x && bombC3x > sx2) && (sy2 == bombC3y || bombC3y == sy1)))
  144.         {
  145.             bombResult += 50;
  146.         }
  147.         else if ((sx1 == bombC3x && sy1 == bombC3y) || (sx2 == bombC3x && sy2 == bombC3y) || (sx1a == bombC3x && sy1a == bombC3y) || (sx2a == bombC3x && sy2a == bombC3y))
  148.         {
  149.             bombResult += 25;
  150.         }
  151.         else
  152.         {
  153.             bombResult += 0;
  154.         }
  155.         // result
  156.         Console.WriteLine("{0}%", bombResult);
  157.     }
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement