Solved

# clock problem for Answer 2000

Posted on 1998-11-01

Here is my problem. How can I modify this code to time the "enter" operation? I'm using the Stopwatch class unmodified to do the timing. I'm looking for the program to print the total time, the average time per "enter" and the min and max time for the "enter"operations.

while (cin>>name)

{

table.enter(name);

}

--------------------------

class Stopwatch

{public:

Stopwatch() : sum (0) {}

void start() {begin = clock();}

double stop() {double res = (double) (clock()-begin);

sum += res;

return res / CLOCKS_PER_SEC;

}

double total() {return sum / CLOCKS_PER_SEC;}

private:

double sum;

clock_t begin;

};