Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  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.  
  11. namespace P1
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18.  
  19. }
  20. double delta,x1,x2;
  21. double rezultat;
  22. private void textBox1_TextChanged(object sender, EventArgs e)
  23. {
  24.  
  25. }
  26.  
  27. private void button1_Click(object sender, EventArgs e)
  28. {
  29. if (checkBox1.Checked)
  30. {
  31. int s1 = Convert.ToInt32(textBox1.Text);
  32. int s2 = Convert.ToInt32(textBox2.Text);
  33. int s3 = Convert.ToInt32(textBox5.Text);
  34. delta = s2 * s2 - 4 * s1 * s3;
  35. if (delta > 0)
  36. {
  37. x1 = ((-s2) + Math.Sqrt(delta)) / (2.0 * s1);
  38. x1 = ((-s2) - Math.Sqrt(delta)) / (2.0 * s1);
  39. }
  40. if (delta == 0)
  41. {
  42. x1 = -s2 / (2.0 * s1);
  43. x2 = -s2 / (2.0 * s1);
  44. }
  45. if (delta <0)
  46. {
  47. x1 = -s2 / (2.0 * s1);
  48. x2 = Math.Sqrt(-delta) / (2.0 * s1);
  49. }
  50. textBox6.Text = "x1= " + Convert.ToString(x1) + "; x2= " + Convert.ToString(x2);
  51. }
  52. if(checkBox2.Checked)
  53. {
  54. string functie = listBox1.Text;
  55. if (functie == "sin(x)")
  56. rezultat = Math.Asin(Convert.ToDouble(textBox7.Text));
  57. if (functie == "cos(x)")
  58. rezultat = Math.Acos(Convert.ToDouble(textBox7.Text));
  59. if (functie == "tg(x)")
  60. rezultat = Math.Atan(Convert.ToDouble(textBox7.Text));
  61. if (functie == "ctg(x)")
  62. rezultat = 1/Math.Atan(Convert.ToDouble(textBox7.Text));
  63. textBox6.Text = rezultat.ToString();
  64. }
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement