コード例 #1
0
 private void btnLagrangePolonomial_Click(object sender, EventArgs e)
 {
     if (lbxPoints.Items.Count < 2)
     {
         MessageBox.Show("Please, add some points to get a polonomial!");
     }
     else
     {
         points = new int[lbxPoints.Items.Count * 2];
         int index = 0;
         for (int i = 0; i < lbxPoints.Items.Count; i++)
         {
             string point = lbxPoints.Items[i].ToString();
             string s     = point.Substring(0, 1);
             while (s != ")")
             {
                 if (s == "(")
                 {
                     point = point.Substring(1);
                     s     = point.Substring(0, 1);
                 }
                 else if (s == ",")
                 {
                     point = point.Substring(1);
                     s     = point.Substring(0, 1);
                 }
                 else
                 {
                     string number = "";
                     while (s != "," && s != ")")
                     {
                         number = number + s;
                         point  = point.Substring(1);
                         s      = point.Substring(0, 1);
                     }
                     points[index] = Convert.ToInt32(number);
                     index++;
                 }
             }
         }
         treePolonomialL = treePolonomialL.MakePolonomialFunctionLagrange(points);
         draw.DrawFunctionPolLa(treePolonomialL);
         lblFunction.Text = treePolonomialL.Read();
     }
 }