Advertisement
BloodMoonYTC

PontOsztalya

Oct 19th, 2021
770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 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 pontosztalya
  8. {
  9.     class pont
  10.     {
  11.         double x, y; //privát adat tagok (default)
  12.         public pont(double a, double b)
  13.         {
  14.             x = a;
  15.             y = b;
  16.         }
  17.  
  18.         public double aps()
  19.         {
  20.             return x;
  21.         }
  22.  
  23.         public double ord()
  24.         {
  25.             return y;
  26.         }
  27.  
  28.         public double tavolsag(pont p)
  29.         {
  30.             double d;
  31.             d=Math.Sqrt(Math.Pow(x-p.x,2)+Math.Pow(y-p.y,2));
  32.             return d;
  33.         }
  34.  
  35.         public void ir(pont p)
  36.         {
  37.             Console.WriteLine(p.x + "," + p.y);
  38.         }
  39.     }
  40.  
  41.     class Program
  42.     {
  43.         static void Main(string[] args)
  44.         {
  45.             double x1, x2, y1, y2;
  46.             Console.WriteLine("Az első pont koordinátái: ");
  47.             Console.Write("x1: ");
  48.             x1 = double.Parse(Console.ReadLine());
  49.             Console.Write("y1: ");
  50.             y1 = double.Parse(Console.ReadLine());
  51.  
  52.             Console.WriteLine("Az masodik pont koordinátái: ");
  53.             Console.Write("x2: ");
  54.             x2 = double.Parse(Console.ReadLine());
  55.             Console.Write("y2: ");
  56.             y2 = double.Parse(Console.ReadLine());
  57.  
  58.             pont p1 = new pont(x1, y1);
  59.             pont p2 = new pont(x2, y2);
  60.  
  61.             Console.Write("Az elso pont ");
  62.             Console.WriteLine(+p1.aps()
  63.  
  64.         }
  65.     }
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement