Advertisement
Guest User

Treci zad 2 grupa

a guest
Nov 11th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 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 Zad3
  8. {
  9. class Program
  10. {
  11. struct Tacka
  12. {
  13. int x, y;
  14. }
  15.  
  16. static double Povrsina(Tacka t1, Tacka t2, Tacka t3)
  17. {
  18. double a, b, c, p, o, s;
  19. a = Math.Sqrt(Math.Pow(t1.x - t2.x, 2) + Math.Pow(t1.y - t2.y, 2));
  20. b = Math.Sqrt(Math.Pow(t1.x - t3.x, 2) + Math.Pow(t1.y - t3.y, 2));
  21. c = Math.Sqrt(Math.Pow(t3.x - t2.x, 2) + Math.Pow(t3.y - t2.y, 2));
  22. o = a + b + c;
  23. s = o / 2;
  24. p = Math.Sqrt(s * (s - a) * (s - b) * (s - c));
  25. return p;
  26. }
  27. static void Main(string[] args)
  28. {
  29. Console.WriteLine("Unesi koordinate tacaka");
  30. double p;
  31. Tacka t1, t2, t3;
  32. t1.x = Convert.ToInt32(Console.ReadLine());
  33. t1.y = Convert.ToInt32(Console.ReadLine());
  34. t2.x = Convert.ToInt32(Console.ReadLine());
  35. t2.y = Convert.ToInt32(Console.ReadLine());
  36. t3.y = 0;
  37. t3.x = 0;
  38. p = Povrsina(t1, t2, t3);
  39. Console.Write("{0}", p);
  40. Console.ReadKey();
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement