using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _2119170006
{
public partial class 多项式求解 : Form
{
public 多项式求解()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double sum = 0, t = -1;
int n = 1;
//input
do
{
t = Math.Pow(-1,n+1) * 1.0 / (2 * n - 1);
if (Math.Abs(t) < 0.0001) break;
sum += t;
n++;
} while (true);
this.label3.Text = (sum * 4).ToString();
}
private void button2_Click(object sender, EventArgs e)
{
double sum = 1, t=1,x;
int n=1;
//input
if(double.TryParse(textBox1.Text,out x)==false)
{
MessageBox.Show("输入错误");
this.textBox1.Focus();
this.textBox1.SelectAll();
return;
}
this.textBox2.Text=(Math.Exp(x).ToString(".000"));
}
}
}
C#算法练习,求e,求π
最新推荐文章于 2022-04-29 15:08:03 发布