比较两个具有相同输入的列表中的元素

时间:2019-07-06 00:11:06

标签: c# mathematical-optimization

我有一些数字,我将它们应用于两个不同的方程式,然后将结果存储到两个不同的列表中,我想比较这些列表中的元素,但只比较那些来自同一输入的结果。所以我想代码从第一个列表中选取一个元素,从第二个列表中选取另一个元素,这是产生第一个列表元素的相同输入的结果。

输入是从Excel工作表导入的数字

例如,如果我输入的数字为1,2,3,4,5 和两个方程x + y = ?? ,x ^ 2 + y ^ 2 = ??

3 + 4 = 7、3 ^ 2 + 4 ^ 2 = 25

我想从两个列表中查找元素25、7以获得输入(3,4)

   for (int m = 0; m < Weights.Count; m++)
       {
         int offset = m * ListCranelocations.Count;

          for (int i = 0; i < ListCranelocations.Count; i++)
            {
                for (int j = 0; j < ListPickLocations.Count; j++)
                {
                    double x = ListCranelocations[i].Lat - ListPickLocations[j].Lat;
                    double y = ListCranelocations[i].Lng - ListPickLocations[j].Lng;
                    R1[i] = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));

                    if (R1[i] > Clearance)
                    {

                        result1[i + offset, j] = Weights[m] * R1[i];

                        //Console.WriteLine(result1[i, j]);
                    }

                }
            }
        }


for (int i = 0; i < ListCranelocations.Count; i++)
        {
            for (int j = 0; j < ListPickLocations.Count; j++)
            {
                for (int k = 0; k < ListSetlocations.Count; k++)
                {
                    double C1 = ListPickLocations[j].Lat - ListCranelocations[i].Lat;
                    double V1 = ListPickLocations[j].Lng - ListCranelocations[i].Lng;
                    double C2 = ListSetlocations[k].Lat - ListCranelocations[i].Lat;
                    double V2 = ListSetlocations[k].Lng - ListCranelocations[i].Lng;
                    double C3 = Math.Sqrt(Math.Pow(C1, 2) + Math.Pow(V1, 2));
                    double V3 = Math.Sqrt(Math.Pow(C2, 2) + Math.Pow(V2, 2));

                    Seta = Math.Acos(((C1 * C2) + (V1 * V2)) / (C3 * V3));
                    Angles.Add(Seta * (180 / Math.PI));

                    counter++;

                }
            }
        }

0 个答案:

没有答案
相关问题