Advertisement
VladSmirN

Untitled

Dec 29th, 2021
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace LangProgKT3
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var random = new Random();
  14. int m = 10;
  15. var array = new double[m, 2];
  16.  
  17. double x = 3;
  18. double y = 3;
  19.  
  20.  
  21.  
  22. for (int i = 0; i < m; i++)
  23. {
  24. array[i, 0] = random.Next(-10, 10);//x
  25. array[i, 1] = random.Next(-10, 10);//y
  26.  
  27. }
  28. for (int i = 0; i < m; i++)
  29. {
  30. Console.Write(array[i, 0] + " " + array[i, 1]);
  31. Console.WriteLine();
  32. }
  33. Console.WriteLine();
  34. Console.Write("x="+ x +" y= "+y );
  35. Console.WriteLine();
  36. double max = -1;
  37. double maxX = 0;
  38. double maxY=0;
  39. for (int i = 0; i < m; i++)
  40. {
  41. double d = Math.Sqrt((array[i, 0] - x) * (array[i, 0] - x) + (array[i, 1] - y) * (array[i, 1] - y));
  42. if(d> max)
  43. {
  44. maxX = array[i, 0];
  45. maxY = array[i, 1];
  46. max = d;
  47. }
  48.  
  49. }
  50. Console.Write("max dist : x=" + maxX + " y= " + maxY);
  51. Console.WriteLine();
  52. Console.ReadLine();
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement