54 lines
1.6 KiB
C#
54 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;
|
|
}
|
|
|
|
bool check = x + y > z && x + z > y && y + z > x;
|
|
|
|
ResultText.Text = check ? "Треугольник существует." :
|
|
"Треугольник не существует.";
|
|
}
|
|
private void ClickBack(object sender, RoutedEventArgs e) => Close();
|
|
|
|
public TriangleWindow()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
}
|
|
}
|