Advertisement
cd62131

Statistics

Jul 28th, 2014
722
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.43 KB | None | 0 0
  1. #!/usr/bin/awk -f
  2. BEGIN {
  3.   field[4] = "英語"
  4.   field[5] = "数学"
  5.   field[6] = "国語"
  6.   field[7] = "理科"
  7.   field[8] = "社会"
  8.   for (i in field) {
  9.     sum[i] = 0
  10.     max[i] = 0
  11.     min[i] = 100
  12.   }
  13. }
  14. {
  15.   nr++;
  16.   for (i in field) {
  17.     sum[i] += $i
  18.     if (max[i] < $i) { max[i] = $i }
  19.     if (min[i] > $i) { min[i] = $i }
  20.   }
  21. }
  22. END {
  23.   for (i in field) {
  24.     print field[i], sum[i] / nr, max[i], min[i]
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement