Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LangProgKT3
- {
- class Program
- {
- static void Main(string[] args)
- {
- var random = new Random();
- int m = 10;
- var array = new double[m, 2];
- double x = 3;
- double y = 3;
- for (int i = 0; i < m; i++)
- {
- array[i, 0] = random.Next(-10, 10);//x
- array[i, 1] = random.Next(-10, 10);//y
- }
- for (int i = 0; i < m; i++)
- {
- Console.Write(array[i, 0] + " " + array[i, 1]);
- Console.WriteLine();
- }
- Console.WriteLine();
- Console.Write("x="+ x +" y= "+y );
- Console.WriteLine();
- double max = -1;
- double maxX = 0;
- double maxY=0;
- for (int i = 0; i < m; i++)
- {
- double d = Math.Sqrt((array[i, 0] - x) * (array[i, 0] - x) + (array[i, 1] - y) * (array[i, 1] - y));
- if(d> max)
- {
- maxX = array[i, 0];
- maxY = array[i, 1];
- max = d;
- }
- }
- Console.Write("max dist : x=" + maxX + " y= " + maxY);
- Console.WriteLine();
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement