Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 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.  
  8.  
  9. namespace ConsoleApplication1
  10. {
  11. class Program
  12. {
  13. public class konty
  14. {
  15.  
  16. public int a;
  17. public int b;
  18. public int c;
  19.  
  20. public konty(int bok)
  21. {
  22. a = b = c = bok;
  23.  
  24. }
  25.  
  26. public konty(int _a, int _b, int _c)
  27. {
  28. a = _a;
  29. b = _b;
  30. c = _c;
  31. }
  32.  
  33. public int obw()
  34. {
  35. return a + b + c;
  36. }
  37.  
  38. public double pole()
  39. {
  40. int p = this.obw() / 2;
  41. return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
  42. }
  43. }
  44.  
  45.  
  46. static void Main(string[] args)
  47. {
  48. konty kont = new konty(5);
  49. konty prost = new konty(2, 1, 2);
  50.  
  51. Console.WriteLine("\nPierwszy = " + kont.obw() + " pole = " + kont.pole());
  52. Console.WriteLine("Drugi = " + prost.obw() + " pole = " + prost.pole());
  53.  
  54.  
  55. Console.ReadKey();
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement