/// <summary>
 /// 100以内3个数的加减法运算
 /// </summary>
 /// <returns>算式</returns>
 public string Expression1003()
 {
     if (CaseNum1 == 0)
     {
         if (CaseNum2 == 0)
         {
             if (this.Num1 + this.Num2 + this.Num3 <= 100)
             {
                 return(Num1.ToString() + "+" + Num2.ToString() + "+" + Num3.ToString());
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             if (this.Num1 + this.Num2 - this.Num3 <= 100 && this.Num1 + this.Num2 - this.Num3 >= 0)
             {
                 return(Num1.ToString() + "+" + Num2.ToString() + "-" + Num3.ToString());
             }
             else
             {
                 return(null);
             }
         }
     }
     else
     {
         if (CaseNum2 == 0)
         {
             if (this.Num1 - this.Num2 >= 0 && this.Num1 - this.Num2 + this.Num3 <= 100)
             {
                 return(Num1.ToString() + "-" + Num2.ToString() + "+" + Num3.ToString());
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             if (this.Num1 - this.Num2 - this.Num3 >= 0)
             {
                 return(Num1.ToString() + "-" + Num2.ToString() + "-" + Num3.ToString());
             }
             else
             {
                 return(null);
             }
         }
     }
 }
Esempio n. 2
0
 private void btn4_Click(object sender, RoutedEventArgs e)
 {
     if (Operation == "")
     {
         Num1           = (Num1 * 10) + 4;
         txtResult.Text = Num1.ToString();
     }
     else
     {
         Num2           = (Num2 * 10) + 4;
         txtResult.Text = Num2.ToString();
     }
 }
Esempio n. 3
0
 private void btnNegative_Click(object sender, RoutedEventArgs e)
 {
     if (Operation == "")
     {
         Num1          *= -1;
         txtResult.Text = Num1.ToString();
     }
     else
     {
         Num2          *= -1;
         txtResult.Text = Num2.ToString();
     }
 }
Esempio n. 4
0
        //Send data to saveData.txt
        private void SetSaveData()
        {
            string[] data = new string[] { saveFileFirstLine, Output, Num1.ToString(), OutputSmall, sign.ToString(), mode.ToString(), memoryExists.ToString(), memory.ToString() };

            using (StreamWriter sw = new StreamWriter(saveFile))
            {
                foreach (string str in data)
                {
                    sw.WriteLine(str);
                }

                sw.Close();
            }
        }
 /// <summary>
 /// 100以内2个数的加减法运算
 /// </summary>
 /// <returns>算式</returns>
 public string Expression1002()
 {
     if (this.Num1 + this.Num2 <= 100)
     {
         return(Num1.ToString() + "+" + Num2.ToString());
     }
     else if (this.Num1 - this.Num2 >= 0)
     {
         return(Num1.ToString() + "-" + Num2.ToString());
     }
     else
     {
         return(Num2.ToString() + "-" + Num1.ToString());
     }
 }
Esempio n. 6
0
        public void reduce()
        {
            String s1      = Num1.ToString();
            String s2      = Num2.ToString();
            bool   isexist = s1.Contains(s2);

            if (isexist)
            {
                int    i  = s1.IndexOf(s2);
                string s3 = s1.Remove(i, s2.Length);
                Console.WriteLine("进行减法运算的结果" + s3.ToString() + "  " + i + "   " + s2.Length);
            }
            else
            {
                Console.WriteLine("无法进行减法运算");
            }
        }
Esempio n. 7
0
        public override string ToString()
        {
            var sb   = new StringBuilder("Work(");
            int tmp1 = 0;

            if (__isset.num1)
            {
                if (0 < tmp1++)
                {
                    sb.Append(", ");
                }
                sb.Append("Num1: ");
                Num1.ToString(sb);
            }
            if (__isset.num2)
            {
                if (0 < tmp1++)
                {
                    sb.Append(", ");
                }
                sb.Append("Num2: ");
                Num2.ToString(sb);
            }
            if (__isset.op)
            {
                if (0 < tmp1++)
                {
                    sb.Append(", ");
                }
                sb.Append("Op: ");
                Op.ToString(sb);
            }
            if ((Comment != null) && __isset.comment)
            {
                if (0 < tmp1++)
                {
                    sb.Append(", ");
                }
                sb.Append("Comment: ");
                Comment.ToString(sb);
            }
            sb.Append(')');
            return(sb.ToString());
        }
Esempio n. 8
0
        public override string ToString()
        {
            string result = String.Empty;

            if (Num1 != null)
            {
                result += Num1.ToString() + " ";
                if (Action != null)
                {
                    result += Action + " ";
                }
                if (Num2 != null)
                {
                    result += Num2.ToString();
                }
            }
            else
            {
                result = "0";
            }

            return(result);
        }
Esempio n. 9
0
        /// <summary>
        /// definition + operator for Nstring data type
        /// </summary>
        /// <param name="Num1"></param>
        /// <param name="Num2"></param>
        /// <returns></returns>
        public static NString operator +(NString Num1, NString Num2)
        {
            int maxLen;

            string maxnum;
            string minnum;

            StringBuilder build;

            if (Num1.Length > Num2.Length)
            {
                maxnum = Num1.ToString();
                minnum = InitMinNum(Num2.ToString(), Num1.Length, Num2.Length);

                maxLen = maxnum.Length;

                build = new StringBuilder(maxLen + 1);
            }
            else if (Num2.Length > Num1.Length)
            {
                maxnum = Num2.ToString();
                minnum = InitMinNum(Num2.ToString(), Num2.Length, Num1.Length);

                maxLen = maxnum.Length;

                build = new StringBuilder(maxLen + 1);
            }
            else
            {
                maxnum = "0" + Num1.ToString();
                minnum = "0" + Num2.ToString();

                maxLen = maxnum.Length;

                build = new StringBuilder(maxLen + 1);
            }

            int n1;
            int n2;
            int save = 0;
            int result;
            int sum;

            int i = maxLen - 1;


            for (; i >= 0; i--)
            {
                n1 = int.Parse(maxnum[i].ToString());
                n2 = int.Parse(minnum[i].ToString());

                sum = n1 + n2 + save;

                save   = sum / 10;
                result = sum % 10;

                build.Append(result);
            }

            if (save != 0)
            {
                build.Append(save);
            }

            string res = Reverse(build.ToString());


            return(new NString(res));
        }
Esempio n. 10
0
 public override string ToString()
 {
     return(Num1.ToString() + GetOperationTav(Operation) + Num2.ToString());
 }
Esempio n. 11
0
 public List <string> GetAllValues()
 {
     return(new List <string> {
         Num1.ToString(), Num2.ToString(), Num3.ToString()
     });
 }
Esempio n. 12
0
        //public void add()
        //{
        //    int db2 = Num1 + Num2;
        //    Console.WriteLine("进行加法运算的结果为" + db2);
        //}
        //public void reduce()
        //{
        //    int db3 = Num1 - Num2;
        //    Console.WriteLine("进行减法运算的结果" + db3);
        //}
        /// <summary>
        /// //////重构
        /// </summary>
        public void add()
        {
            String db2 = Num1.ToString() + Num2.ToString();

            Console.WriteLine("进行加法运算的结果为" + db2);
        }