Advertisement
triplex239

поиск S & P у круга и треугольник

Sep 18th, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.96 KB | None | 0 0
  1. namespace Kopylov.HelloWorld
  2. {
  3.     class MathConst
  4.     {
  5.         public const double p = 3.14;
  6.  
  7.     }
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Console.WriteLine("У нас треугольник или круг?: ");
  13.             string figura = Convert.ToString(Console.ReadLine());
  14.             string upperFigura = figura.ToUpper();
  15.             if (upperFigura == "ТРЕУГОЛЬНИК")
  16.             {
  17.                 Console.WriteLine("Что найдём? S или P ");
  18.                 string poisk = Convert.ToString(Console.ReadLine());
  19.                 string UpperPoisk = poisk.ToUpper();
  20.                 Console.WriteLine("введите сторону треугольника x: ");
  21.                 double x = Convert.ToDouble(Console.ReadLine());
  22.                 Console.WriteLine("введите сторону треугольника y: ");
  23.                 double y = Convert.ToDouble(Console.ReadLine());
  24.                 Console.WriteLine("введите сторону треугольника z: ");
  25.                 double z = Convert.ToDouble(Console.ReadLine());
  26.                 if (poisk == "S")
  27.                 {
  28.                     Console.WriteLine("Площадь = "+Square(x, y, z));
  29.                 }
  30.                 else
  31.                 {
  32.                     Console.WriteLine("Периметр = "+Perimeter(x, y, z));
  33.                 }
  34.                
  35.                     Console.WriteLine("Хотетите определить прямоугольый ли треуголник? да/нет: ");
  36.                     string otvet = Convert.ToString(Console.ReadLine());
  37.                 if (otvet == "да")
  38.                 {
  39.                     if (Rectangular(x, y, z))
  40.                     {
  41.                         Console.WriteLine("Треугольник прямоугольный");
  42.                     }
  43.                     else if (Rectangular(x,y,z))
  44.                     {
  45.                         Console.WriteLine("Треугольник не прямоугольный");
  46.                         //Console.WriteLine("Треугольник" + Rectangular(x, y, z));
  47.                     }
  48.                     else
  49.                     {
  50.                         if ((x == y)||(x==z)||(z==y))
  51.                         {
  52.                             Console.WriteLine("Треугольник равнобедренный");
  53.                         }
  54.                     }
  55.                 }
  56.                
  57.             }
  58.             else if (upperFigura == "КРУГ")
  59.                 Console.WriteLine("введите радиус r: ");
  60.             double r = Convert.ToDouble(Console.ReadLine());
  61.             Console.WriteLine("Что найдём? S или P ");
  62.             char a = Convert.ToChar(Console.ReadLine());
  63.             if (a == 'S')
  64.             {
  65.                 Console.WriteLine("Площадь = "+Square(r));
  66.             }
  67.             else
  68.             {
  69.                 Console.WriteLine("Периметр = "+Perimeter(r));
  70.             }
  71.             Console.ReadKey();
  72.  
  73.  
  74.         }
  75.         static double Square(double x, double y, double z)
  76.         {
  77.             return Math.Sqrt(Perimeter(x, y, z) * (Perimeter(x, y, z) - x) * (Perimeter(x, y, z) - y) * (Perimeter(x, y, z) - z));
  78.         }
  79.         static double Square(double b)
  80.         {
  81.             return b * b * MathConst.p;
  82.         }
  83.         static double Perimeter(double x, double y, double z)
  84.         {
  85.             return (x + y + z) / 2;
  86.         }
  87.         static double Perimeter(double r)
  88.         {
  89.             return r * Math.PI;
  90.         }
  91.         static bool Rectangular(double x, double y,double z)
  92.         {
  93.  
  94.             return ((x * x == y * y + z * z) || (z * z == x * x + y * y) || (y * y == z * z + x * x));
  95.            // Console.WriteLine("Прямоугольный");
  96.             //else
  97.            // Console.WriteLine("Не прямоугольный");
  98.            
  99.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement