Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Kopylov.HelloWorld
- {
- class MathConst
- {
- public const double p = 3.14;
- }
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("У нас треугольник или круг?: ");
- string figura = Convert.ToString(Console.ReadLine());
- string upperFigura = figura.ToUpper();
- if (upperFigura == "ТРЕУГОЛЬНИК")
- {
- Console.WriteLine("Что найдём? S или P ");
- string poisk = Convert.ToString(Console.ReadLine());
- string UpperPoisk = poisk.ToUpper();
- Console.WriteLine("введите сторону треугольника x: ");
- double x = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("введите сторону треугольника y: ");
- double y = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("введите сторону треугольника z: ");
- double z = Convert.ToDouble(Console.ReadLine());
- if (poisk == "S")
- {
- Console.WriteLine("Площадь = "+Square(x, y, z));
- }
- else
- {
- Console.WriteLine("Периметр = "+Perimeter(x, y, z));
- }
- Console.WriteLine("Хотетите определить прямоугольый ли треуголник? да/нет: ");
- string otvet = Convert.ToString(Console.ReadLine());
- if (otvet == "да")
- {
- if (Rectangular(x, y, z))
- {
- Console.WriteLine("Треугольник прямоугольный");
- }
- else if (Rectangular(x,y,z))
- {
- Console.WriteLine("Треугольник не прямоугольный");
- //Console.WriteLine("Треугольник" + Rectangular(x, y, z));
- }
- else
- {
- if ((x == y)||(x==z)||(z==y))
- {
- Console.WriteLine("Треугольник равнобедренный");
- }
- }
- }
- }
- else if (upperFigura == "КРУГ")
- Console.WriteLine("введите радиус r: ");
- double r = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("Что найдём? S или P ");
- char a = Convert.ToChar(Console.ReadLine());
- if (a == 'S')
- {
- Console.WriteLine("Площадь = "+Square(r));
- }
- else
- {
- Console.WriteLine("Периметр = "+Perimeter(r));
- }
- Console.ReadKey();
- }
- static double Square(double x, double y, double z)
- {
- return Math.Sqrt(Perimeter(x, y, z) * (Perimeter(x, y, z) - x) * (Perimeter(x, y, z) - y) * (Perimeter(x, y, z) - z));
- }
- static double Square(double b)
- {
- return b * b * MathConst.p;
- }
- static double Perimeter(double x, double y, double z)
- {
- return (x + y + z) / 2;
- }
- static double Perimeter(double r)
- {
- return r * Math.PI;
- }
- static bool Rectangular(double x, double y,double z)
- {
- return ((x * x == y * y + z * z) || (z * z == x * x + y * y) || (y * y == z * z + x * x));
- // Console.WriteLine("Прямоугольный");
- //else
- // Console.WriteLine("Не прямоугольный");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement