本帖最后由 guang5930 于 2013-08-11 19:08:22 编辑

解决方案 »

  1.   

    int[][] data = new int[][]
    {
        new int[] { 1, 2, 5 },
        new int[] { 1, 3, 2 },
        new int[] { 2, 3, 8 }
    };
    int 方案总数 = data.Select(x => x[0]).Concat(data.Select(x => x[1])).Distinct().Count();
    double[,] arr = new double[方案总数, 方案总数];
    for (int i = 0; i < 方案总数; i++)
    {
        for (int j = 0; j < 方案总数; j++)
        {
            if (i == j) arr[i, j] = 1;
            if (i < j)
                arr[i, j] = data.Single(x => x[0] == i && x[1] == j)[2];
            else
                arr[i, j] = 1 / data.Single(x => x[0] == j && x[1] == i)[2];
        }
    }大概写写的。
      

  2.   

    可能我说得不清楚,是这样的,有一个类如下:
    class ProjectInfo
    {
        public ProjectInfo(string itemName1,string itemName2,int value)
        {
            ItemName1 = itemName1;
            ItemName2 = itemName2;
            ItemValue = value;
        }
        public string ItemName1;
        public string ItemName2;
        public int ItemValue;
    }
    然后有一个List
    List<ProjectInfo> proList = new List<ProjectInfo>();
    proList.Add(new ProjectInfo("方案1","方案2",5);
    proList.Add(new ProjectInfo("方案1","方案3",2);
    proList.Add(new ProjectInfo("方案2","方案3",8);现在要得到这样的一个Table:
              方案1  方案2  方案3
    方案1      1      5      2
    方案2     1/5     1      8
    方案3     1/2    1/8     1