CS140 Midterm Exam - October 5, 2004 - Page 6


Question 6

You are writing a program that digests input files like inputfile. The program's name is digest.c, and it reads its input from standard input. The format of an input file is that each line contains a name (any number of words, no word may be a number), then a number n of scores, and then n scores. Note, inputfile adheres to this format. For example, Tiger Woods's line has four scores: 72, 64, 70, 71. Scores are floating point numbers.

There may be comment lines which begin with '#' as the first character on the line -- these should be ignored.

You are to write a program that reads in a file of this format, and prints out for each line:

Therefore running digest < inputfile will yield:

   69.2500 Tiger Woods
   68.3333 Vijay Singh
   72.2000 Phil Mickelson
   73.5000 Davis Love III
   70.3333 Sergio Garcia
   69.0000 Cher
   99.0000 E. Power Biggs

You may assume that the input file is in the correct format -- in other words, you do not need to do any error checking!!!!