Question: Time.h file //Measure time in Window // Define a Timer object t, use t.start() for beginning of the algorithm, t.stop() for the ending, and t.show()

 Time.h file //Measure time in Window // Define a Timer object
Time.h file
//Measure time in Window
// Define a Timer object t, use t.start() for beginning of the algorithm, t.stop() for the ending, and t.show() for printing.
#ifndef TIMER_H
#define TIMER_H
#include
#include
#include
using namespace std;
class Timer
{
public:
Timer();
Timer(const std::string &label);
~Timer();
void start(void);
void stop(void);
void show(void);
private:
void reset(void);
string label;
long tps;
clock_t
start_time,
end_time;
double
usertime,
systemtime,
elapsedtime,
waittime;
};
#endif
// eof timer.h
// timer.cpp
Timer::Timer ()
{
label = "Process Timer";
reset();
}
Timer::Timer (const std::string &label)
{
Timer::label = label;
reset();
}
Timer::~Timer()
{
}
void
Timer::reset(void)
{
tps = CLOCKS_PER_SEC;
end_time = 0;
usertime = 0;
systemtime = 0;
elapsedtime = 0;
waittime = 0;
}
void
Timer::start(void)
{
start_time = clock();
}
void
Timer::show(void)
{
cout
}
void
Timer::stop(void)
{
end_time = clock();
elapsedtime = ((double)(end_time -
start_time )/(double)tps );
if (elapsedtime
{
elapsedtime = 0.001;
}
if ( waittime
{
waittime = 0.00;
}
}
// eof timer.cpp
Consider a network of streets laid out in a rectangular grid, for example In a northeast path from one point in the grid to another, one may walk only to the north (up) and to the east (right). For example, there are four northeast paths from A to B in the preceding grid Write a program that must use a recursive function to count the number of northeast paths from one point to another in a rectangular grid. Your program should prompt user to input the numbers of points to north and to east respectively, and then output the total number of paths. Note Here is a file timer.h which should be included in your program to measure time in Window or Unix (includes Mac OS and Linux) systems (use start0 for beginning of the algorithm, stop) for the ending, and show0 for printing). Below is an example: e #include "timer"h" using namespace std; void main) ( Timer t t.startO; // do some task t.stop() t.show): // this will print the elapsed time The computing times of this algorithm is very high, and the number of paths may be overflow, don't try input numbers even over 16. Please paste your output as comments at the bottom of your file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!