Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 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 ConsoleApplication20
  8. {
  9. class Punkt
  10. {
  11. private int wspx;
  12. private int wspy;
  13.  
  14. public Punkt(int x, int y)
  15. {
  16. this.wspx = x;
  17. this.wspy = y;
  18. }
  19.  
  20. public void wyswietl()
  21. {
  22. Console.WriteLine("Aktualne wspolrzedne punktu wynoszą: {0}, {1} ", wspx, wspy);
  23. }
  24.  
  25. public static double Odcinek(Punkt[] tab)
  26. {
  27. double dlugosc = Math.Sqrt(Math.Pow(tab[1].wspx - tab[0].wspx, 2) + Math.Pow(tab[1].wspy - tab[0].wspy, 2));
  28. return dlugosc;
  29. }
  30. }
  31.  
  32. class Program
  33. {
  34. static void Main(string[] args)
  35. {
  36. Punkt[] tablica = new Punkt[2];
  37. tablica[0] = new Punkt(1, 1);
  38. tablica[1] = new Punkt(2, 2);
  39.  
  40.  
  41. foreach(Punkt a in tablica)
  42. a.wyswietl();
  43.  
  44. Console.WriteLine(Punkt.Odcinek(tablica));
  45.  
  46. Console.ReadKey();
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement