BorislavBorisov

31.Fighter Attack мое решение

Nov 6th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.29 KB | None | 0 0
  1. using System;
  2. class FighterAttack
  3. {
  4.     static bool isHitted = false;
  5.     static void Main()
  6.     {
  7.         int Px1 = int.Parse(Console.ReadLine());
  8.         int Py1 = int.Parse(Console.ReadLine());
  9.         int Px2 = int.Parse(Console.ReadLine());
  10.         int Py2 = int.Parse(Console.ReadLine());
  11.  
  12.         int Fx = int.Parse(Console.ReadLine());
  13.         int Fy = int.Parse(Console.ReadLine());
  14.  
  15.         int distance = int.Parse(Console.ReadLine());
  16.  
  17.         distance = distance + Fx;
  18.  
  19.         int PxMin = Math.Min(Px1, Px2);
  20.         int PxMax = Math.Max(Px1, Px2);
  21.         int PyMin = Math.Min(Py1, Py2);
  22.         int PyMax = Math.Max(Py1, Py2);
  23.  
  24.        
  25.  
  26.         for (int i = 0; i < 7; i++)
  27.         {
  28.             CkeckForSolution(distance, PxMin, PxMax, PyMin, PyMax, Fy);
  29.             if (isHitted)
  30.             {
  31.                 return;
  32.             }
  33.         }
  34.         if (!isHitted)
  35.         {
  36.             Console.WriteLine(0 + "%");
  37.         }
  38.     }
  39.  
  40.     static void CkeckForSolution(int distance, int PxMin, int PxMax, int PyMin, int PyMax, int Fy)
  41.     {
  42.         if ((distance >= PxMin && distance <= PxMax - 1)
  43.             && (Fy == PyMin || Fy == PyMax))
  44.         {
  45.             Console.WriteLine(225 + "%");
  46.             isHitted = true;
  47.             return;
  48.         }
  49.         if (distance >= PxMin && distance <= PxMax - 1
  50.             && Fy >= PyMin - 1 && Fy <= PyMax - 1)
  51.         {
  52.             Console.WriteLine(275 + "%"); ;
  53.             isHitted = true;
  54.             return;
  55.         }
  56.         if ((distance <= PxMin - 1) && (Fy >= PyMin && Fy <= PyMax))
  57.         {
  58.             Console.WriteLine(75 + "%");
  59.             isHitted = true;
  60.             return;
  61.         }
  62.         if ((distance == PxMax) && (Fy > PyMin  + 1 || Fy < PyMax - 1))
  63.         {
  64.             Console.WriteLine(150 + "%"); ;
  65.             isHitted = true;
  66.             return;
  67.         }
  68.         if ((distance == PxMax) && (Fy == PyMin || Fy == PyMax))
  69.         {
  70.             Console.WriteLine(100 + "%");
  71.             isHitted = true;
  72.             return;
  73.         }
  74.         if ((distance >= PxMin && distance <= PxMax)
  75.             && (Fy == PyMin - 1 || Fy == PyMax + 1))
  76.         {
  77.             Console.WriteLine(50 + "%");
  78.             isHitted = true;
  79.             return;
  80.         }
  81.        
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment