Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ShipDamage
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- class Ship
- {
- public static int Sx1;
- public static int Sx2;
- public static int Sy1;
- public static int Sy2;
- public static int damage;
- }
- class Horizon
- {
- public static int h;
- }
- class Bomb
- {
- public int x;
- public int y;
- }
- class ShipDamage
- {
- static void Main()
- {
- Ship.Sx1 = int.Parse(Console.ReadLine());
- Ship.Sy1 = int.Parse(Console.ReadLine());
- Ship.Sx2 = int.Parse(Console.ReadLine());
- Ship.Sy2 = int.Parse(Console.ReadLine());
- Horizon.h = int.Parse(Console.ReadLine());
- Bomb bomb1 = new Bomb();
- bomb1.x = int.Parse(Console.ReadLine());
- bomb1.y = int.Parse(Console.ReadLine());
- Bomb bomb2 = new Bomb();
- bomb2.x = int.Parse(Console.ReadLine());
- bomb2.y = int.Parse(Console.ReadLine());
- Bomb bomb3 = new Bomb();
- bomb3.x = int.Parse(Console.ReadLine());
- bomb3.y = int.Parse(Console.ReadLine());
- if (Horizon.h>0)
- {
- Ship.Sy1 -= Math.Abs(Horizon.h);
- Ship.Sy2 -= Math.Abs(Horizon.h);
- bomb1.y -= Math.Abs(Horizon.h);
- bomb2.y -= Math.Abs(Horizon.h);
- bomb3.y -= Math.Abs(Horizon.h);
- Horizon.h = Horizon.h - Horizon.h;
- }
- else if (Horizon.h<0)
- {
- Ship.Sy1 += Math.Abs(Horizon.h);
- Ship.Sy2 += Math.Abs(Horizon.h);
- bomb1.y += Math.Abs(Horizon.h);
- bomb2.y +=Math.Abs(Horizon.h);
- bomb3.y += Math.Abs(Horizon.h);
- Horizon.h = Horizon.h + Horizon.h;
- }
- int rightSide = Math.Max(Ship.Sx1, Ship.Sx2);
- int leftSide = Math.Min(Ship.Sx1, Ship.Sx2);
- int upSide = Math.Max(Ship.Sy1, Ship.Sy2);
- int bottomSide = Math.Min(Ship.Sy1, Ship.Sy2);
- Bomb[] bombs = new Bomb[3];
- bombs[0] = bomb1;
- bombs[1] = bomb2;
- bombs[2] = bomb3;
- //check where is hit
- foreach (Bomb bomb in bombs)
- {
- bomb.y = -bomb.y;//reflecting the bomb
- if (bomb.x<rightSide && bomb.x>leftSide)
- {
- if (bomb.y<upSide && bomb.y>bottomSide)
- {
- Ship.damage += 100;
- }
- else if (bomb.y == upSide || bomb.y == bottomSide)
- {
- Ship.damage += 50;
- }
- }
- else if (bomb.x==rightSide || bomb.x == leftSide)
- {
- if (bomb.y<upSide && bomb.y>bottomSide)
- {
- Ship.damage += 50;
- }
- else if (bomb.y==upSide || bomb.y==bottomSide)
- {
- Ship.damage += 25;
- }
- }
- }
- Console.WriteLine(Ship.damage +"%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement