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;
- namespace Vir_4
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Input first_edge");
- string ABAsString = Console.ReadLine();
- double AB = 0;
- if (!double.TryParse(ABAsString, out AB))
- {
- Console.WriteLine(" first_edge input is wrong");
- Console.ReadKey();
- return;
- }
- if (AB <= 0)
- {
- Console.WriteLine("first_edge is wrong");
- Console.ReadKey();
- return;
- }
- Console.WriteLine("Input second_edge");
- string BCAsString = Console.ReadLine();
- double BC = 0;
- if (!double.TryParse(BCAsString, out BC))
- {
- Console.WriteLine(" second_edge input is wrong");
- Console.ReadKey();
- return;
- }
- if (BC <= 0)
- {
- Console.WriteLine("second_edge is wrong");
- Console.ReadKey();
- return;
- }
- Console.WriteLine("Input third_edge");
- string CAAsString = Console.ReadLine();
- double CA = 0;
- if (!double.TryParse(CAAsString, out CA))
- {
- Console.WriteLine(" third_edge input is wrong");
- Console.ReadKey();
- return;
- }
- if (CA <= 0)
- {
- Console.WriteLine("third_edge is wrong");
- Console.ReadKey();
- return;
- }
- // Ввод окончен
- double Cos_1 = (CA*CA - AB*AB + BC*BC) / (2*CA*BC);
- double Cos_2 = (AB*AB - CA*CA + BC*BC) / (2*AB*BC);
- double Cos_3 = (AB*AB - BC*BC + CA*CA) / (2*AB*CA);
- if ((AB != BC) && (BC != CA) && ((Cos_1 < 0) || (Cos_2 < 0) || (Cos_3 < 0)))
- {
- double p = 0.5 * (AB + BC + CA);
- double for_sqrt = p * (p - AB) * (p - BC) * (p - CA);
- if (for_sqrt < 0)
- {
- Console.WriteLine("Tringle are wrong");
- Console.ReadKey();
- return;
- }
- double s = Math.Sqrt(for_sqrt);
- Console.WriteLine("S = {0}", s);
- Console.ReadKey();
- return;
- }
- else
- Console.WriteLine("Tringle are not satisfies the task");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement