Form1_Lab3.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. using static System.Windows.Forms.VisualStyles.VisualStyleElement;
  11. namespace Ul_3
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19. private void button1_Click(object sender, EventArgs e)
  20. {
  21. double x = double.Parse(textBox1.Text);
  22. double y = double.Parse(textBox2.Text);
  23. // решаем уравнение
  24. double result = SolveEquation(x, y);
  25. // выводим результат
  26. textBox3.Text = result.ToString();
  27. }
  28. private double SolveEquation(double x, double y)
  29. {
  30. double result = 0;
  31. if (Math.Abs(x - y) < 0.0001)
  32. {
  33. result = Math.Pow(Math.Sin(x), 2) + Math.Sin(y);
  34. }
  35. else if (x - y > 0)
  36. {
  37. result = Math.Cos(x) + Math.Cos(y);
  38. }
  39. else if (x - y < 0)
  40. {
  41. result = y - Math.Pow(Math.Tan(x), 2) + Math.Tan(y);
  42. }
  43. return result;
  44. }
  45. }
  46. }