mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Updated how results are retrieved
This commit is contained in:
@@ -70,6 +70,11 @@ void Problem27::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "The greatest number of primes found is " << topN
|
||||
<< "\nIt was found with A = " << topA << ", B = " << topB
|
||||
<< "\nThe product of A and B is " << topA * topB;
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -81,21 +86,6 @@ void Problem27::reset(){
|
||||
primes.clear();
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem27::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
results << "The greatest number of primes found is " << topN
|
||||
<< "\nIt was found with A = " << topA << ", B = " << topB
|
||||
<< "\nThe product of A and B is " << topA * topB;
|
||||
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the top A that was generated
|
||||
int64_t Problem27::getTopA() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user