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 pont
- {
- class Program
- {
- static int[] x;
- static int[] y;
- static Random rnd = new Random();
- static void Main(string[] args)
- {
- feltolt(10);
- kiir();
- Console.WriteLine("A legtávolabbi pont: ({0}, {1})", x[Legtavolabbi()],y[Legtavolabbi()]);
- Console.ReadKey();
- }
- static void feltolt(int db)
- {
- x = new int[db];
- y = new int[db];
- for (int i = 0; i < db; i++)
- {
- x[i] = rnd.Next(-10, 10);
- y[i] = rnd.Next(-10, 10);
- }
- }
- static void kiir()
- {
- for (int i = 0; i < x.Length; i++)
- {
- Console.WriteLine("({0}, {1})",x[i],y[i]);
- }
- }
- static int Legtavolabbi()
- {
- int maxInd = 0;
- for (int i = 1; i < x.Length; i++)
- {
- if (Tavolsag(x[i], y[i]) > Tavolsag(x[maxInd], y[maxInd]))
- {
- maxInd = i;
- }
- }
- return 0;
- }
- static double Tavolsag(int x,int y)
- {
- return Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement