Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 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 WindowsFormsApplication1
  12. {
  13. public partial class Form1 : Form
  14. {
  15. double x, y, eps, a, sum, F;
  16. int n;
  17. string s1, s2;
  18. public Form1()
  19. {
  20. InitializeComponent();
  21. }
  22.  
  23. private void Form1_Load(object sender, EventArgs e)
  24. {
  25.  
  26. }
  27.  
  28. private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  29. {
  30.  
  31. }
  32.  
  33. private void button1_Click(object sender, EventArgs e)
  34. {
  35. eps = 0.0001;
  36. for (int i = 0; x<=1; i++)
  37. {
  38. a = x;
  39. sum = 0;
  40. n = 0;
  41. do
  42. {
  43. sum += a;
  44. y = (Math.Pow(x, 2)) / ((2 * n + 2) * (2 * n + 3));
  45. a *= y;
  46. n++;
  47. } while (Math.Abs(a) >= eps);
  48. F = (Math.Exp(x) - Math.Exp(-x)) / 2;
  49. s1 = x.ToString() + " "; s1 = s1.Substring(0, 6);
  50. s2 = sum.ToString() + " "; s2 = s2.Substring(0, 8);
  51. listBox1.Items.Add(s1 = "\t" + " " + s2 + " " + "\t" + F);
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement