返回列表 發帖
create variables, one for the sum and one for the count, then create a loop to prompt user input...

pseudo code should be something like this:

procedure main
   double sum = 0;
   integer count = 0;
   string input = 'exit';

   loop
      input = raw_input('blah blah blah, type exit when done')
      // check input
      sum = sum + int( input )
      count = count + 1
   loop unit input = 'exit'

   if count > 0
      output sum / count
   end if

end procedure

TOP

返回列表