Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _08.Center_Point
{
public class Program
{
public static void Main()
{
ClosestToTheCentre();
}
private static void ClosestToTheCentre()
{
var x1 = double.Parse(Console.ReadLine());
var y1 = double.Parse(Console.ReadLine());
var x2 = double.Parse(Console.ReadLine());
var y2 = double.Parse(Console.ReadLine());
var result = new List<double>();
if (Math.Abs(x1) > Math.Abs(x2))
{
result.Add(x2);
}
else if (Math.Abs(x1) < Math.Abs(x2))
{
result.Add(x1);
}
else
{
result.Add(x2);
}
if (Math.Abs(y1) > Math.Abs(y2))
{
result.Add(y2);
}
else if (Math.Abs(y1) < Math.Abs(y2))
{
result.Add(y1);
}
else
{
result.Add(y2);
}
Console.WriteLine("(" + string.Join(", ", result) + ")");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment