Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.37 KB | None | 0 0
  1. #!/usr/bin/awk -f
  2.  
  3. BEGIN {
  4.     FS="\t"
  5. }
  6.  
  7. /%ЛЮДИ%/ {
  8.     for (i = 2; i <= NF; i++)
  9.         arr[$i] = 0.001
  10.     n = NF - 1
  11.     next
  12. }
  13.  
  14. /^$/ {
  15.     next
  16. }
  17.  
  18. {
  19.     if ($3 != "ВСЕ") {
  20.         arr[$3] += $2
  21.         next
  22.     }
  23.     for (i in arr)
  24.         arr[i] += $2 / n
  25. }
  26.  
  27. END {
  28.     sum=0
  29.     for (i in arr) {
  30.         print i " заплатит " arr[i]
  31.         sum += arr[i]
  32.     }
  33.     print ""
  34.     print "Итого: "sum
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement