x + y = 100;
x - y = 50;举个例子 求解这个方程组 怎样写代码??谢谢  各位老师

解决方案 »

  1.   

    表达式1分析-->取得x 和 y的系数,及常数C1
    表达式2分析-->取得x 和 y的系统,及常数C2如果楼主学过线性代数的话,就知道怎么求解了。
    (我忘了,过程不难,很简单,找本线性代数的书翻一下就出来了)貌似如下:
    |1  1|
    |    |=-2
    |1 -1||100  1|
    |      | = -150
    |50  -1|
    x = (-150) / (-2) = 75|1  100|
    |      | = -50
    |1   50|
    y = (-50) / (-2) = 25楼主看懂上面的算法,写个数组运算就可以解决问题了。
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.Text;namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                 decimal a,b,x,y;
                 Console.WriteLine("已经知道:a = 100,b=50 ");
                 Console.WriteLine("input a and b de zhi:");
                 a = Convert.ToDecimal(Console.ReadLine());
                 b = Convert.ToDecimal(Console.ReadLine());
                 x = (a + b) / 2;
                 y = (a - b) / 2;
                 Console.WriteLine("x = {0}\ty = {1}", x, y);
             
                 Console.ReadKey();
                 
                 
            }
        }
    }
      

  3.   

    aX+bY=c
    eX+fY=g;x=(cf-be)/(af-be);
    y=(ce-ga)/(be-af);解析出abcefg,直接套用结果的公式就可以了。
      

  4.   

    aX+bY=c
    eX+fY=g;x=(cf-be)/(af-be);
    y=(ce-ga)/(be-af);
    这个才能应付所有的 2元一次方程