lmarkov

Ship Damage

Dec 14th, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.86 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 shipSX1 = int.Parse(Console.ReadLine());
  14.             int shipSY1 = int.Parse(Console.ReadLine());
  15.             int shipSX2 = int.Parse(Console.ReadLine());
  16.             int shipSY2 = int.Parse(Console.ReadLine());
  17.             int horizontH = int.Parse(Console.ReadLine());
  18.             int attackCX1 = int.Parse(Console.ReadLine());
  19.             int attackCY1 = int.Parse(Console.ReadLine());
  20.             int attackCX2 = int.Parse(Console.ReadLine());
  21.             int attackCY2 = int.Parse(Console.ReadLine());
  22.             int attackCX3 = int.Parse(Console.ReadLine());
  23.             int attackCY3 = int.Parse(Console.ReadLine());
  24.  
  25.             shipSY1 -= horizontH;
  26.             shipSY2 -= horizontH;
  27.             attackCY1 -= horizontH;
  28.             attackCY2 -= horizontH;
  29.             attackCY3 -= horizontH;
  30.  
  31.             int reflectAttackCY1 = -attackCY1;
  32.             int reflectAttackCY2 = -attackCY2;
  33.             int reflectAttackCY3 = -attackCY3;
  34.  
  35.             int shipTop = Math.Max(shipSY1,shipSY2);
  36.             int shipLeft = Math.Min(shipSX1,shipSX2);
  37.             int shipRight = Math.Max(shipSX1, shipSX2);
  38.             int shipBottom = Math.Min(shipSY1, shipSY2);
  39.  
  40.             int damage = 0;
  41.  
  42.             if (reflectAttackCY1 > shipBottom && reflectAttackCY1 < shipTop)
  43.             {
  44.                 if (attackCX1 > shipLeft && attackCX1 < shipRight)
  45.                 {
  46.                     damage += 100;
  47.                 }
  48.                 else if (attackCX1 == shipLeft || attackCX1 == shipRight)
  49.                 {
  50.                     damage += 50;
  51.                 }
  52.             }
  53.             if (reflectAttackCY1 == shipTop || reflectAttackCY1 == shipBottom)
  54.             {
  55.                 if (attackCX1 > shipLeft && attackCX1 < shipRight)
  56.                 {
  57.                     damage += 50;
  58.                 }
  59.                 else if (attackCX1 == shipLeft || attackCX1 == shipRight)
  60.                 {
  61.                     damage += 25;
  62.                 }
  63.             }
  64.  
  65.  
  66.  
  67.  
  68.             if (reflectAttackCY2 > shipBottom && reflectAttackCY2 < shipTop)
  69.             {
  70.                 if (attackCX2 > shipLeft && attackCX2 < shipRight)
  71.                 {
  72.                     damage += 100;
  73.                 }
  74.                 else if (attackCX2 == shipLeft || attackCX2 == shipRight)
  75.                 {
  76.                     damage += 50;
  77.                 }
  78.             }
  79.             if (reflectAttackCY2 == shipTop || reflectAttackCY2 == shipBottom)
  80.             {
  81.                 if (attackCX2 > shipLeft && attackCX2 < shipRight)
  82.                 {
  83.                     damage += 50;
  84.                 }
  85.                 else if (attackCX2== shipLeft || attackCX2 == shipRight)
  86.                 {
  87.                     damage += 25;
  88.                 }
  89.             }
  90.  
  91.  
  92.  
  93.             if (reflectAttackCY3 > shipBottom && reflectAttackCY3 < shipTop)
  94.             {
  95.                 if (attackCX3 > shipLeft && attackCX3 < shipRight)
  96.                 {
  97.                     damage += 100;
  98.                 }
  99.                 else if (attackCX3 == shipLeft || attackCX3 == shipRight)
  100.                 {
  101.                     damage += 50;
  102.                 }
  103.             }
  104.             if (reflectAttackCY3 == shipTop || reflectAttackCY3 == shipBottom)
  105.             {
  106.                 if (attackCX3 > shipLeft && attackCX3 < shipRight)
  107.                 {
  108.                     damage += 50;
  109.                 }
  110.                 else if (attackCX3 == shipLeft || attackCX3 == shipRight)
  111.                 {
  112.                     damage += 25;
  113.                 }
  114.             }
  115.             Console.WriteLine(damage + "%");
  116.         }        
  117.     }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment