Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 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 WindowsFormsApp5
  12. {
  13.    
  14.     public partial class Form1 : Form
  15.     {
  16.         int n = 1;
  17.  
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.  
  23.         private void button1_Click(object sender, EventArgs e)
  24.         {
  25.             double S = 0;
  26.             double Sk;
  27.             double y;
  28.          
  29.             double x = Convert.ToDouble(textBox1.Text);
  30.             if (x <= 1 && x >= 0.1f)
  31.             {
  32.                 for (int i = 1; i <= 10; i++)
  33.                 {
  34.                    
  35.                     S+=  Math.Pow(x, 2 * i) / (Factorial(2 * i));
  36.                    
  37.                 }
  38.                 Sk = 1 + S;
  39.  
  40.                 y = (Math.Pow((Math.E),x) + Math.Pow((Math.E), -x)) / 2;
  41.  
  42.            
  43.  
  44.                 textBox2.Text = Sk.ToString();
  45.                 textBox3.Text = y.ToString();
  46.            
  47.             }
  48.             else
  49.             {
  50.                 MessageBox.Show ("Введите 0.1<=x<=1" );
  51.             }
  52.  
  53.  
  54.         }
  55.  
  56.  
  57.  
  58.         static long Factorial(long x)
  59.         {
  60.             return (x == 0) ? 1 : x * Factorial(x - 1);
  61.         }
  62.  
  63.  
  64.  
  65.  
  66.         static void FuncH(int H, int xn,int xk)
  67.         {
  68.             H = (xk - xn) / 10;
  69.         }
  70.  
  71.    
  72.  
  73.         private void textBox1_TextChanged(object sender, EventArgs e)
  74.         {
  75.            
  76.         }
  77.  
  78.         private void label1_Click(object sender, EventArgs e)
  79.         {
  80.  
  81.         }
  82.  
  83.         private void textBox2_TextChanged(object sender, EventArgs e)
  84.         {
  85.  
  86.         }
  87.  
  88.         private void textBox3_TextChanged(object sender, EventArgs e)
  89.         {
  90.  
  91.         }
  92.  
  93.         private void button2_Click(object sender, EventArgs e)
  94.         {
  95.             textBox1.Text = "";
  96.             textBox2.Text = "";
  97.             textBox3.Text = "";
  98.         }
  99.  
  100.         private void button3_Click(object sender, EventArgs e)
  101.         {
  102.             Close();
  103.         }
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement