Advertisement
Guest User

Untitled

a guest
Sep 13th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.35 KB | None | 0 0
  1. {
  2. iloczyn=1
  3. nr_of_fields=0
  4. for(i=1;i<=NF;i++){
  5.  
  6.     if($i ~ /^-*[1-9][0-9]*$/){
  7.         iloczyn*=$i
  8.         srednia[NR]+=$i
  9.         nr_of_fields++
  10.     }
  11. }
  12.    
  13.     if(iloczyn < 0 && iloczyn%2==0){
  14.         srednia[NR]/=nr_of_fields
  15.     }
  16.     else srednia[NR]=0
  17. }
  18.  
  19. END{
  20.     for ( x in srednia ) {
  21.         if (srednia[x]==0)continue
  22.         printf "w linii " x " srednia to " srednia[x]"\n"
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement