Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Asen_Kursova;
- namespace Asen_Kursova
- {
- internal class Program
- {
- static void Main (string[]args)
- {
- Points[]points = new Points[10];
- String[]names = {"first","second","third","forth","fifth","sixth","seventh","eighth","ninth","tenth"}
- int bestIndex = -1;
- double distance = -1;
- for (int i = 0; i < points.Length; i++)
- {
- Points current = new Points();
- current.Name = names[i];
- Console.WriteLine ($ "distance number {i+1} is ");
- points[i] = current;
- points[i].InputDots ();
- points[i].AreaOfDots ();
- if (points[i].Distance > distance)
- {
- distance = points[i].Distance;
- bestIndex = i;
- }
- }
- Console.WriteLine ($"The biggest distance is {points[bestIndex].Name} with distance {points[bestIndex].Distance:f2}");
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Vladislav_Kursova
- {
- internal class Points
- {
- private double x1, y1, x2, y2, distance;
- private string name;
- public Points (){}
- public Points (double x_1, double y_1, double x_2, double y_2,double areas, string name)
- {
- this.x1 = x_1;
- this.y1 = y_1;
- this.x2 = x_2;
- this.y2 = y_2;
- this.distance = areas;
- this.name = name;
- }
- public double X1
- {
- set = >x1 = value;
- }
- public double Y1
- {
- set = >y1 = value;
- }
- public double X2
- {
- set = >x2 = value;
- }
- public double Y2
- {
- set = >y2 = value;
- }
- public double Distance
- {
- get = >distance;
- }
- public string Name
- {
- get = >name;
- set = >name = value;
- }
- public void InputDots ()
- {
- Console.Write ("enter x1 ");
- x1 = double.Parse (Console.ReadLine ());
- Console.Write ("enter y1 ");
- y1 = double.Parse (Console.ReadLine ());
- Console.Write ("enter x2 ");
- x2 = double.Parse (Console.ReadLine ());
- Console.Write ("enter y2 ");
- y2 = double.Parse (Console.ReadLine ());
- }
- public double AreaOfDots () = >distance =
- Math.Sqrt (Math.Pow (x2 - x1, 2) + Math.Pow (y2 - y1, 2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement