06. Three brothers C++
Това е моят недописан код, колеги. 50/100. Моля ви да ми помогнете с вашата логика, крашва ми когато някой от братята не е работил тоест въведа 0 в конзолата.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double timeA, timeB, timeC, timeD ;
cin >> timeA >> timeB >> timeC >> timeD;
double haveTime = timeA+timeB+timeC+timeD;
haveTime = haveTime / ( haveTime / timeA + haveTime / timeB + haveTime / timeC );
haveTime = haveTime+ haveTime * 0.15 ;
cout.setf( ios::fixed );
cout.precision( 2 );
cout << "Cleaning time: "<< haveTime << endl;
if ( haveTime >= 0 && haveTime <= timeD ) {
cout.setf(ios::fixed);
cout.precision( 0 );
cout << "Yes, there is a surprise - time left " <<"-> " << floor(timeD - haveTime) << " hours." << endl;
}else if ( haveTime >=0 && haveTime >= timeD) {
cout.setf ( ios::fixed );
cout.precision( 0 );
cout << "No, there isn't a surprise - shortage of time "<<"-> " << floor(haveTime + timeD) << " hours." << endl;
}
return 0 ;
}