Form1.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace PR6
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void button1_Click(object sender, EventArgs e)
  19. {
  20. int a = Convert.ToInt32(textBox2.Text);
  21. int b = Convert.ToInt32(textBox1.Text);
  22. int c = Convert.ToInt32(textBox3.Text);
  23. if (a < b + c && b < a + c && c < a + b)
  24. {
  25. if (a == b && a == c && c == b)
  26. {
  27. label6.Text = "равносторонний";
  28. }
  29. else if (a == b || a == c || b == c)
  30. {
  31. label6.Text = "равнобедренный";
  32. }
  33. else
  34. {
  35. label6.Text = "разносторонний";
  36. }
  37. }
  38. else
  39. {
  40. label6.Text = "треугольник не существует";
  41. }
  42. }
  43. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  44. {
  45. char number = e.KeyChar;
  46. if (!Char.IsDigit(number) && number != 8)
  47. {
  48. e.Handled = true;
  49. }
  50. }
  51. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  52. {
  53. char number = e.KeyChar;
  54. if (!Char.IsDigit(number) && number != 8)
  55. {
  56. e.Handled = true;
  57. }
  58. }
  59. private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
  60. {
  61. char number = e.KeyChar;
  62. if (!Char.IsDigit(number) && number != 8)
  63. {
  64. e.Handled = true;
  65. }
  66. }
  67. }
  68. }