예제 #1
0
파일: Form1.cs 프로젝트: LatyninG/Atta2
 private void solveBTN_Click(object sender, EventArgs e)
 {
     try
     {
         string level = MessageBoxUtils.DialogBoxTree("Enter the level's number", "Set the task params");
         int    y     = 0;
         if (level == "" || !(Int32.TryParse(level, out y)) || y < 0)
         {
             throw new Exception();
         }
         if (y <= levelamount)
         {
             int x = tree.CountTree(levelamount, levelamount - y);//n-уровней всего,k-искомый уровень
             MessageBox.Show("Value's sum on the chosen level: " + Convert.ToString(x), "Result");
         }
         else
         {
             MessageBox.Show("Our tree hasnt got this level", "Error");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Enter the correct value");
     }
 }
예제 #2
0
파일: Form1.cs 프로젝트: LatyninG/Atta2
 private void generateBTN_Click(object sender, EventArgs e)
 {
     try
     {
         string levelsAndChance = MessageBoxUtils.DialogBoxTree("Enter the amount of levels and their generation chance", "Ввод");
         if (levelsAndChance == "")
         {
             throw new Exception();
         }
         string[] str = levelsAndChance.Split(' ');
         if (str.Length > 2)
         {
             throw new Exception();
         }
         levelamount = Convert.ToInt32(str[0]);
         double chance = Convert.ToDouble(str[1]);
         tree.RandomTreeGenerator(levelamount, chance);
         MyDraw();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Enter the correct value", "Error");
     }
 }