(a+b)*2=100  a*b*c=300  这样么?

解决方案 »

  1.   

    using System;namespace ConsoleApplication4
    {
        class Program
        {
            static void Main(string[] args)
            {
                double A = 100 / 2;
                double B = Math.Sqrt(A * A - 300 * 4);
                Console.WriteLine("Width = {0} Height = {1}", (A + B) / 2, (A - B) / 2);
            }
        }
    }
      

  2.   

    using System; namespace ConsoleApplication4 

        class Program 
        { 
            static void Main(string[] args) 
            { 
                double A = 100 / 2; 
                double B = Math.Sqrt(A * A - 300 * 4); 
                Console.WriteLine("Width = {0} Height = {1}", (A + B) / 2, (A - B) / 2); 
            } 
        } 
    }
    正解
      

  3.   

    这个方法似乎更符合程序员的思维(牛顿迭代),也可以支持更高的精度。using System;namespace ConsoleApplication4
    {
        class Program
        {
            static void Main(string[] args)
            {
                double area = 300, girth = 50, length = 25, temp = 0;            while (temp != length)
                {
                    temp = length;
                    length = area / length;
                    length = girth - length;
                }            Console.WriteLine("Width = {0} Height = {1}", length, girth - length);
            }
        }
    }
      

  4.   

    for(int i=1;i<100/2;i++)
    {
       for(int j=1;j<100/2;j++)
       {
          if((i+j)*2==100)
          {
              if(i*j==300)
              {
                   Console.WriteLine("Width = {0} Height = {1}", i, j); 
              }
          }
       }
    }