简体   繁体   English

分析和比较 2 个列表

[英]Analyzing and Comparing 2 Lists

i know this sounds like im asking for a spoon to be fed to me, but i am really fuzzed up and stuck on formulating several logics but still can't find the real deal.我知道这听起来像是我在要求给我喂勺子,但我真的很困惑并坚持制定几个逻辑,但仍然找不到真正的交易。

my current system's goal is to analyze a student's grade and exam results to assess which college major is fit for him.我当前系统的目标是分析学生的成绩和考试成绩,以评估哪个大学专业适合他。

i have completed almost all of the system's functionality except the equation for this one.我已经完成了系统的几乎所有功能,除了这个等式。

assuming that假如说

I  = Grades Result
II = Examination Result

A = Major A
B = Major B
C = Major C

so the table would look something like所以桌子看起来像

   | A  |  B  |  C  |
---------------------
I  |    |     |     |
---------------------
II |    |     |     |

i need to formulate a result where i can assess several possible scenarios, like:我需要制定一个结果,我可以评估几种可能的情况,例如:

   |  A  |  B  |  C  |
---------------------
I  |  1  |  2  |  3  |
---------------------
II |  1  |  3  |  2  |

in the table about, Major A had a rank of both 1 on I and II .在表中, Major AIII上的排名都是1 So without further equations, the student is best to pick Major A .所以没有进一步的方程,学生最好选择Major A

and, in:并且,在:

   |  A  |  B  |  C  |
---------------------
I  |  1  |  2  |  3  |
---------------------
II |  3  |  2  |  1  |

Major B had a rank of both 2 on I and II . Major BIII上的排名均为2 So like the first example in which the student got a stable result on both I and II , the student is best to pick Major B .所以就像第一个学生在III上都得到稳定结果的例子一样,学生最好选择Major B

here:这里:

   |  A  |  B  |  C  |
---------------------
I  |  3  |  2  |  1  |
---------------------
II |  3  |  2  |  1  |

all three Majors have stable results in both I and II .所有三个MajorsIII都有稳定的结果。 But, in terms of ranking, Major C had the highest post so the student is off picking Major C .但是,就排名而言, Major C的职位最高,因此该学生不会选择Major C

and this is the trickiest part for me:这对我来说是最棘手的部分:

   |  A  |  B  |  C  |
---------------------
I  |  1  |  2  |  3  |
---------------------
II |  2  |  1  |  3  |

Major C is the only one that had a stable result result. Major C是唯一一个结果稳定的人。 But given that it's post is 3 , Major C is out of the equation.但鉴于它的职位是3Major C不在等式之外。 and therefore, a calculation will be performed.因此,将进行计算。 Where:在哪里:

I =  60%
II = 40%

so 

Major A will be ((0.6 x 1) + (0.4 x 2)) = 1.4
Major B will be ((0.6 x 2) + (0.4 x 1)) = 1.6

Thus given in the equation, Major A had a higher ranking result over Major B .因此,在等式中, Major A的排名结果高于Major B So the student will be given Major A as the top pick for Majors因此,学生将获得Major A作为专业的首选


i am really really really having a hard time thinking of a way to translate the equation and idea to a code where i will be utilizing two List<> .我真的真的真的很难想出一种方法来将方程式和想法转换为我将使用两个List<> One for I and one for II .一个用于I ,一个用于II

so if someone could really really pick me up here, i would greatly appreciate it.所以如果有人真的能来这里接我,我将不胜感激。 i've ran out of idea to spare with this one.我已经没有想法可以用这个了。 thank you谢谢你

i have below code written and i know it is as ugly as it can be.我写了下面的代码,我知道它尽可能丑陋。

List<Ranking> Rank = new List<Ranking>();

// if all results are distinct to each other OR if all results are equal
if(
    (ExamResult[0].MajorResult != GradeResult[0].MajorResult && ExamResult[1].MajorResult != GradeResult[1].MajorResult && ExamResult[2].MajorResult != GradeResult[2].MajorResult)
  ||
    (ExamResult[0].MajorResult == GradeResult[0].MajorResult && ExamResult[1].MajorResult == GradeResult[1].MajorResult && ExamResult[2].MajorResult == GradeResult[2].MajorResult)
  )
{
    Rank.Add(new Ranking() { Name = ExamResult.Where(x => x.MajorID == 1).Select(x => x.MajorDescription).Single(), Value = ExamResult.Where(x => x.MajorID == 1).Select(x => x.MajorResult).Single() + GradeResult.Where(x => x.MajorID == 1).Select(x => x.MajorResult).Single() });
    Rank.Add(new Ranking() { Name = ExamResult.Where(x => x.MajorID == 2).Select(x => x.MajorDescription).Single(), Value = ExamResult.Where(x => x.MajorID == 2).Select(x => x.MajorResult).Single() + GradeResult.Where(x => x.MajorID == 2).Select(x => x.MajorResult).Single() });
    Rank.Add(new Ranking() { Name = ExamResult.Where(x => x.MajorID == 3).Select(x => x.MajorDescription).Single(), Value = ExamResult.Where(x => x.MajorID == 3).Select(x => x.MajorResult).Single() + GradeResult.Where(x => x.MajorID == 3).Select(x => x.MajorResult).Single() });
}

// if one of the three is equal
if(ExamResult[0].MajorResult == GradeResult[0].MajorResult || ExamResult[1].MajorResult == GradeResult[1].MajorResult || ExamResult[2].MajorResult == GradeResult[2].MajorResult)
{
    var LowestRank1 = ExamResult.OrderBy(x => x.MajorResult).Last();
    var LowestRank2 = GradeResult.OrderBy(x => x.MajorResult).Last();

    var HighestRank1 = ExamResult.OrderBy(x => x.MajorResult).First();
    var HighestRank2 = GradeResult.OrderBy(x => x.MajorResult).First();

    if((ExamResult[0].MajorResult == LowestRank1.MajorResult) && (GradeResult[0].MajorResult == LowestRank2.MajorResult))
    {
        Rank.Add(new Ranking() { Name = ExamResult.Where(x => x.MajorID == 2).Select(x => x.MajorDescription).Single(), Value = (ExamResult.Where(x => x.MajorID == 2).Select(x => x.MajorResult).Single() * 0.4) + (GradeResult.Where(x => x.MajorID == 2).Select(x => x.MajorResult).Single() * 0.6) });
        Rank.Add(new Ranking() { Name = ExamResult.Where(x => x.MajorID == 3).Select(x => x.MajorDescription).Single(), Value = (ExamResult.Where(x => x.MajorID == 3).Select(x => x.MajorResult).Single() * 0.4) + (GradeResult.Where(x => x.MajorID == 3).Select(x => x.MajorResult).Single() * 0.6) });
    }

    if((ExamResult[1].MajorResult == LowestRank1.MajorResult) && (GradeResult[1].MajorResult == LowestRank2.MajorResult))
    {
        Rank.Add(new Ranking() { Name = ExamResult.Where(x => x.MajorID == 1).Select(x => x.MajorDescription).Single(), Value = (ExamResult.Where(x => x.MajorID == 1).Select(x => x.MajorResult).Single() * 0.4) + (GradeResult.Where(x => x.MajorID == 1).Select(x => x.MajorResult).Single() * 0.6) });
        Rank.Add(new Ranking() { Name = ExamResult.Where(x => x.MajorID == 3).Select(x => x.MajorDescription).Single(), Value = (ExamResult.Where(x => x.MajorID == 3).Select(x => x.MajorResult).Single() * 0.4) + (GradeResult.Where(x => x.MajorID == 3).Select(x => x.MajorResult).Single() * 0.6) });
    }

    if((ExamResult[2].MajorResult == LowestRank1.MajorResult) && (GradeResult[2].MajorResult == LowestRank2.MajorResult))
    {
        Rank.Add(new Ranking() { Name = ExamResult.Where(x => x.MajorID == 1).Select(x => x.MajorDescription).Single(), Value = (ExamResult.Where(x => x.MajorID == 1).Select(x => x.MajorResult).Single() * 0.4) + (GradeResult.Where(x => x.MajorID == 1).Select(x => x.MajorResult).Single() * 0.6) });
        Rank.Add(new Ranking() { Name = ExamResult.Where(x => x.MajorID == 2).Select(x => x.MajorDescription).Single(), Value = (ExamResult.Where(x => x.MajorID == 2).Select(x => x.MajorResult).Single() * 0.4) + (GradeResult.Where(x => x.MajorID == 2).Select(x => x.MajorResult).Single() * 0.6) });
    }
}

assuming that假如说

I  = Grades Result
II = Examination Result

A = Major A
B = Major B
C = Major C

you can calculate points for every major like:您可以计算每个专业的分数,例如:

((1 << (A.I - 1)) * 0.6) + ((1 << (A.II - 1)) * 0.4)

the same for major B and C. the lower the best.大调 B 和 C 相同。越低越好。

First table:
A = 1;
B = 1.8;
C = 3.2;
Second:
A = 2.2;
B = 2;
C = 2.8;
Third:
A = 4;
B = 2;
C = 1;
Fourth:
A = 1.4;
B = 1.6;
C = 4;

this works only because you said the best result is 1. you can shift only by 7 on int and 15 on int64.这只是因为你说最好的结果是 1。你只能在 int 上移动 7,在 int64 上移动 15。

let me know if you have Grade or Examination results > of 7 or 15如果您的成绩或考试成绩 > 7 或 15,请告诉我

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM