Skip to content

Instantly share code, notes, and snippets.

@macrat
Last active June 15, 2016 05:24
Show Gist options
  • Save macrat/e93afa9205d353b9d2501610b2edd610 to your computer and use it in GitHub Desktop.
Save macrat/e93afa9205d353b9d2501610b2edd610 to your computer and use it in GitHub Desktop.
06/15日のC#勉強会で出した課題の解答例(LINQ版)
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