Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Doesn't fully work!
- using System;
- namespace LongerLine
- {
- class Program
- {
- static void Main(string[] args)
- {
- int NumOfPoints = 4; int ArraySize = (int)Math.Log(1.0 * NumOfPoints, 2);
- double[] Point = new double[NumOfPoints * 2];
- double[] LineDistance = new double[ArraySize];
- int Index = 0; double LastDistance = 0; int MaxIndex = 0;
- for (int j = -1, i = 0; i < NumOfPoints; i++)
- {
- Point[Index++] = double.Parse(Console.ReadLine());
- Point[Index++] = double.Parse(Console.ReadLine());
- if ((i + 1) % 2 == 0)
- {
- LineDistance[++j] = FindDistanceOfLine(Point[Index - 4], Point[Index - 3], Point[Index - 2], Point[Index - 1]);
- if(LastDistance == LineDistance[j])
- {
- MaxIndex = j - 1;
- }
- else if (LastDistance < LineDistance[j])
- {
- LastDistance = LineDistance[j];
- MaxIndex = j;
- }
- }
- }
- double Distance1 = FindDistanceToPoint(Point[MaxIndex * NumOfPoints], Point[MaxIndex * NumOfPoints + 1]);
- double Distance2 = FindDistanceToPoint(Point[MaxIndex * NumOfPoints + 2], Point[MaxIndex * NumOfPoints + 3]);
- if(Distance2 > Distance1)
- {
- Console.WriteLine($"({Point[MaxIndex * NumOfPoints]}, {Point[MaxIndex * NumOfPoints + 1]})" +
- $"({Point[MaxIndex * NumOfPoints + 2]}, {Point[MaxIndex * NumOfPoints + 3]})");
- }
- else
- {
- Console.WriteLine($"({Point[MaxIndex * NumOfPoints + 2]}, {Point[MaxIndex * NumOfPoints + 3]})" +
- $"({Point[MaxIndex * NumOfPoints]}, {Point[MaxIndex * NumOfPoints + 1]})");
- }
- }
- static double FindDistanceOfLine(double Point1, double Point2, double Point3, double Point4)
- {
- return Math.Abs(Math.Sqrt(Math.Pow((Point3 - Point1), 2) + Math.Pow((Point4 - Point2), 2)));
- }
- static double FindDistanceToPoint(double X, double Y)
- {
- return Math.Abs(Math.Sqrt(Math.Pow(X, 2) + Math.Pow(Y, 2)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement