Skip to content

Instantly share code, notes, and snippets.

@geekontheway
Created October 4, 2014 15:07
Show Gist options
  • Save geekontheway/ffd79ed43d4042ae043f to your computer and use it in GitHub Desktop.
Save geekontheway/ffd79ed43d4042ae043f to your computer and use it in GitHub Desktop.
绩点算法
# 学分,成绩,绩点,5分制
arr = [[2, 90, 4], [1, 99, 4.9], [2, 96, 4.6], [1, 80, 3], [2, 86, 3.6], [2, 90, 4], [1, 92, 4.2], [2, 82, 3.2], [2, 88, 3.8], [3, 96, 4.6], [3, 96, 4.6], [2.5, 90, 4.0], [2.5, 100, 5], [2.5, 90, 4], [2.5, 93, 4.3], [1.5, 94, 4.4], [2, 96, 4.6], [2, 89, 3.9], [3, 87, 3.7], [3.5, 99, 4.9], [3, 91, 4.1], [3, 99, 4.9], [5, 96, 4.6], [5, 86, 3.6], [5, 90, 4], [3, 96, 4.6], [3.5, 96, 4.6], [3, 87, 3.7], [3, 95, 4.5], [3.5, 98, 4.8], [6, 80, 3], [5, 92, 4.2], [5, 93, 4.3], [3.5, 94, 4.4], [3, 94, 4.4], [3, 90, 4], [3, 98, 4.8], [3, 88, 3.8], [3, 85, 3.5], [3, 83, 3.3], [2, 79, 2.9], [2, 84, 3.4], [3, 89, 3.9], [3, 85, 3.5], [3, 84, 3.4], [3, 86, 3.6], [3, 82, 3.2], [2, 80, 3], [1, 97, 4.7], [2, 66, 1.6], [6, 94, 4.4], [1, 98, 4.8], [1, 81, 3.1], [1, 90, 4], [1, 90, 4], [1, 89, 3.9], [1, 84.9, 3.4], [1, 89.6, 3.9]]
arr.each do |sub|
alls+= sub[0]*sub[2]
allv+=sub[0]
end
gpa = alls/allv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment