IN C++, WRITE CODE FOR GIVEN PROJECT USING PROVIDED .HFILE. WRITE IN COMMENTS SO I CAN UNDERSTAND WHAT NEEDS/IS BEINGDONE. I WOULD LIKE TO LEARN AND UNDERSTAND THIS,AND NOT JUST BE GIVEN SOMEONE ELSES ANSWER YOUALREADY SOLVED.
PROVIDED .H FILE NEEDED FOR ASSIGNMENT
// timer.h // Measures time in Window// Define a Timer object t, use t.start() for beginning of thealgorithm, t.stop()for the ending, and t.show() for printing.#ifndef TIMER_H#define TIMER_H#include <ctime>#include <string>#include <iostream>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_tstart_time,end_time;doubleusertime,systemtime,elapsedtime,waittime;};#endif// eof timer.h// timer.cppTimer::Timer (){label = "Process Timer";reset();}Timer::Timer (const std::string &label)
{Timer::label = label;reset();}Timer::~Timer(){}voidTimer::reset(void){tps = CLOCKS_PER_SEC;end_time = 0;usertime = 0;systemtime = 0;elapsedtime = 0;waittime = 0;}voidTimer::start(void){start_time = clock();}voidTimer::show(void){cout << " "<< label << "\n"<< " -------------------------------\n"<< " Elapsed Time : "<< elapsedtime<< "s" << std::endl;}voidTimer::stop(void){end_time = clock();elapsedtime = ((double)(end_time -start_time )/(double)tps );if (elapsedtime < 0.001){elapsedtime = 0.001;}if ( waittime < 0.00 ){waittime = 0.00;}}// eof timer.cpp
SAMPLE RUN:
Objective To get practice in designing recursive functions and to gain experience in algorithm time efficiency. Project Description Consider a network of streets laid out in a rectangular grid, for example B 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: A B A A B A B A B 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.
How many points north of A is B? 2 How many points east of A is B? 3 There are 10 northeast paths between A and B. Process Timer Elapsed Time: 0.01s Enter y or Y to continue next example or any other letter to exit: y How many points north of A is B? 12 How many points east of A is B? 14 There are 9657700 northeast paths between A and B. Process Timer Elapsed Time: 1.081s Enter y or Y to continue next example or any other letter to exit: y How many points north of A is B? 16 How many points east of A is B? 16 There are 601080390 northeast paths between A and B. Process Timer Elapsed Time: 62.79s Enter y or Y to continue next example or any other letter to exit: Upload your source code file assignment10.cpp for the assignment below.
IN C++, WRITE CODE FOR GIVEN PROJECT USING PROVIDED .H FILE. WRITE IN COMMENTS SO I CAN UNDERSTAND WHAT NEEDS/IS BEING D
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am