# mean.pc # # Prints the mean of the absolute values of the elements of an array. # --- Initial data --- +0 000 000 000 # 000 - constant 0 +0 000 000 000 # 001 - index +0 000 000 000 # 002 - sum +0 000 000 000 # 003 - average +0 000 000 000 # 004 - count +0 000 000 000 # 005 - temp # 006...999 - array +9999999999 # --- Program text --- # Load array. +8 ... ... 004 # 000 - read number of elements +8 ... ... 005 # 001 - read value into temp +5 005 000 004 # 002 - if positive, skip -1 000 005 005 # 003 - else negate -6 005 006 001 # 004 - move temp into array[index] +7 001 004 001 # 005 - incr index, test with count, loop to 001 # Find array sum. +0 000 000 001 # 006 - reset index to zero +6 006 001 005 # 007 - get array[index] +1 005 002 002 # 008 - and add to sum +7 001 004 007 # 009 - incr index, test with count, loop to 007 # Find and display average. -2 002 004 003 # 010 - set average to sum / count -8 003 ... ... # 011 - print average +9 ... ... ... # 000 - halt +9999999999 # --- Input cards --- +0 000 000 011 # 000 - number of cards in array +0 000 000 000 -0 000 000 001 +0 000 000 002 -0 000 000 003 +0 000 000 004 -0 000 000 005 +0 000 000 006 -0 000 000 007 +0 000 000 008 -0 000 000 009 +0 000 000 010 # vim: set ft=conf: