Advertisement
neron476

6_условный_оператор

Sep 9th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Vir_4
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Console.WriteLine("Input first_edge");
  13. string ABAsString = Console.ReadLine();
  14. double AB = 0;
  15. if (!double.TryParse(ABAsString, out AB))
  16. {
  17. Console.WriteLine(" first_edge input is wrong");
  18. Console.ReadKey();
  19. return;
  20. }
  21. if (AB <= 0)
  22. {
  23. Console.WriteLine("first_edge is wrong");
  24. Console.ReadKey();
  25. return;
  26. }
  27. Console.WriteLine("Input second_edge");
  28. string BCAsString = Console.ReadLine();
  29. double BC = 0;
  30. if (!double.TryParse(BCAsString, out BC))
  31. {
  32. Console.WriteLine(" second_edge input is wrong");
  33. Console.ReadKey();
  34. return;
  35. }
  36. if (BC <= 0)
  37. {
  38. Console.WriteLine("second_edge is wrong");
  39. Console.ReadKey();
  40. return;
  41. }
  42. Console.WriteLine("Input third_edge");
  43. string CAAsString = Console.ReadLine();
  44. double CA = 0;
  45. if (!double.TryParse(CAAsString, out CA))
  46. {
  47. Console.WriteLine(" third_edge input is wrong");
  48. Console.ReadKey();
  49. return;
  50. }
  51. if (CA <= 0)
  52. {
  53. Console.WriteLine("third_edge is wrong");
  54. Console.ReadKey();
  55. return;
  56. }
  57.  
  58. // Ввод окончен
  59. double Cos_1 = (CA*CA - AB*AB + BC*BC) / (2*CA*BC);
  60. double Cos_2 = (AB*AB - CA*CA + BC*BC) / (2*AB*BC);
  61. double Cos_3 = (AB*AB - BC*BC + CA*CA) / (2*AB*CA);
  62. if ((AB != BC) && (BC != CA) && ((Cos_1 < 0) || (Cos_2 < 0) || (Cos_3 < 0)))
  63. {
  64. double p = 0.5 * (AB + BC + CA);
  65. double for_sqrt = p * (p - AB) * (p - BC) * (p - CA);
  66. if (for_sqrt < 0)
  67. {
  68. Console.WriteLine("Tringle are wrong");
  69. Console.ReadKey();
  70. return;
  71. }
  72. double s = Math.Sqrt(for_sqrt);
  73. Console.WriteLine("S = {0}", s);
  74. Console.ReadKey();
  75. return;
  76. }
  77. else
  78. Console.WriteLine("Tringle are not satisfies the task");
  79. Console.ReadKey();
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement