namespace 运算符穷举
{
    class Program
    {
        static void Main(string[] args)
        {   //123()45()68=100; 在括号里面添加+ -使等式成立 
            int a; int b; 
            for (int i = 0; i < 2; i++)    //有0 和1 两种可能, 0代表加法,1代表减法
            {
                for (int j = 0; j < 2; j++)
                {
                    if (i == 0)
                    {
                         a = 1;
                    }
                    else
                    {
                         a = -1;
                    }
                    if (j == 0)
                    {
                         b = 1;
                    }
                    else
                    {
                        b = -1;
                    }
                    if(123+a*45+b*68==100)  //定义的a b 是为了输出加法的运算符  当a=1为加法,a=-1为减法,b也一样
                    {
                    if(a==1)
                    {
                        Console.Write("第一格为加法,");
                    }
                    else
                    {
                        Console.Write("第一格为减法,");
                    }
                    if (b== 1)
                    {
                        Console.WriteLine("第二格为加法");
                    }
                    else
                    {
                        Console.WriteLine("第二格为减法");
                    }
                    }
                }
            }
            Console.ReadLine();
        }
    }
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-06
  • 2021-09-18
  • 2021-10-12
  • 2021-10-11
猜你喜欢
  • 2022-12-23
  • 2021-11-11
  • 2021-07-30
  • 2021-09-23
  • 2021-07-30
相关资源
相似解决方案