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 ConsoleApplication20
- {
- class Punkt
- {
- private int wspx;
- private int wspy;
- public Punkt(int x, int y)
- {
- this.wspx = x;
- this.wspy = y;
- }
- public void wyswietl()
- {
- Console.WriteLine("Aktualne wspolrzedne punktu wynoszą: {0}, {1} ", wspx, wspy);
- }
- public static double Odcinek(Punkt[] tab)
- {
- double dlugosc = Math.Sqrt(Math.Pow(tab[1].wspx - tab[0].wspx, 2) + Math.Pow(tab[1].wspy - tab[0].wspy, 2));
- return dlugosc;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Punkt[] tablica = new Punkt[2];
- tablica[0] = new Punkt(1, 1);
- tablica[1] = new Punkt(2, 2);
- foreach(Punkt a in tablica)
- a.wyswietl();
- Console.WriteLine(Punkt.Odcinek(tablica));
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement