Last active
June 15, 2016 05:24
-
-
Save macrat/e93afa9205d353b9d2501610b2edd610 to your computer and use it in GitHub Desktop.
06/15日のC#勉強会で出した課題の解答例(LINQ版)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Linq; | |
| using CampusSquare; | |
| class Example2 { | |
| public static void Main() { | |
| var grades = new CampusSquare.DummyCampusSquare("record.html").GetGrades(); | |
| Console.WriteLine("GPA: " + ( | |
| (double)grades.Select(x => x.GradeNum * x.CreditNum).Sum() | |
| / | |
| grades.Select(x => x.CreditNum).Sum() | |
| )); | |
| Console.WriteLine("\ngood: "); | |
| foreach(var grade in grades.Where(x => x.GradeNum == grades.Select(y => y.GradeNum).Max())){ | |
| Console.WriteLine(" " + grade.Grade + ": " + grade.Name); | |
| } | |
| Console.WriteLine("\nbad: "); | |
| foreach(var grade in grades.Where(x => x.GradeNum == grades.Select(y => y.GradeNum).Min())){ | |
| Console.WriteLine(" " + grade.Grade + ": " + grade.Name); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment