57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace Lab
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for TriangleWindow.xaml
|
|
/// </summary>
|
|
|
|
|
|
public partial class TriangleWindow : Window
|
|
{
|
|
private void ClickCheck(object sender, RoutedEventArgs e) {
|
|
if (!Parsers.TryParseDouble(XBox.Text, out double x) ||
|
|
!Parsers.TryParseDouble(YBox.Text, out double y) ||
|
|
!Parsers.TryParseDouble(ZBox.Text, out double z))
|
|
{
|
|
ResultText.Text = "Введите три положительных числа (например: 2.5).";
|
|
return;
|
|
}
|
|
|
|
if (x <=0 ||
|
|
y <=0 ||
|
|
z <=0)
|
|
{
|
|
ResultText.Text = "Стороны должны быть строго положительными.";
|
|
return;
|
|
}
|
|
|
|
double[] s = { x, y, z };
|
|
Array.Sort(s);
|
|
|
|
bool check = s[0] > s[2] - s[1];
|
|
|
|
ResultText.Text = check ? "Треугольник существует." :
|
|
"Треугольник не существует.";
|
|
}
|
|
private void ClickBack(object sender, RoutedEventArgs e) => Close();
|
|
|
|
public TriangleWindow()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
}
|
|
}
|