1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include <iostream>
#include <iomanip>
using namespace std;
void meet(const double d, const double v0, const double v1, const double &time, const double &distance0, const double &distance1); //Function Declaration goes here
int main(void)
{
double d, v0, v1, time, distance0, distance1;
cout << "Enter d, v0, v1: ";
cin >> d >> v0 >> v1;
meet(d, v0, v1, time, distance0, distance1);
cout << fixed << setprecision(3);
cout << "Time is " << time << " distance0 is " << distance0
<< " distance1 is " << distance1 << endl;
return 0;
}
void meet(const double d, const double v0, const double v1, const double &time, const double &distance0, const double &distance1)// First line of the function goes here
{
time = d / (v0 + v1);
dist0 = v0 * time;
dist1 = v1 * time;
}
|