예제 #1
0
파일: LoTV.cs 프로젝트: Mexahoid/CSF
 private void ctrlBaton_Click(object sender, EventArgs e)
 {
     MyList = new ListLogicClass();
       try
       {
     for (int i = ctrlDGVIn.RowCount - 2; i >= 0; i--)
     {
       MyList.AddToList(double.Parse(Convert.ToString(ctrlDGVIn.Rows[i].Cells[0].Value)));
     }
     switch (Answer.Go(MyList))
     {
       case 1:
     MessageBox.Show("Возрастает");
     break;
       case 2:
     MessageBox.Show("Убывает");
     break;
       case 3:
     MessageBox.Show("Ни возрастает, ни убывает");
     break;
     }
       }
       catch
       {
     MessageBox.Show("Неправильные числа", "Ошибка");
       }
 }
예제 #2
0
파일: Answer.cs 프로젝트: Mexahoid/CSF
        public static int Go(ListLogicClass InputList)
        {
            bool High = true;
              bool Down = false;
              double MinEl = int.MaxValue;
              double MaxEl = int.MinValue;
              ListNodeClass Head = InputList.ListHead;

              if (Head != null)
              {
            do
            {
              MaxEl = Head.NodeValue;
              MinEl = Head.NodeValue;
              Head = Head.NodeNext;
              if (Head != null)
              {
            if (MinEl < Head.NodeValue && High)
              High = true;
            else
              High = false;

            if (!High)
            {
              if (MaxEl > Head.NodeValue)
                Down = true;
              else
              {
                Down = false;
                break;
              }
            }
              }
            }
            while (Head != null);
              }

              switch (High)
              {
            case true:
              return 1;

            case false:
              if (Down)
            return 2;
              else
            return 3;
              }
              return 3;
        }