mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-07 01:23:57 -05:00
Updated how results are retrieved
This commit is contained in:
@@ -66,6 +66,9 @@ void Problem12::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "The triangular number " << sum << " is a sum of all numbers >= " << counter - 1 << " and has " << divisors.size() << " divisors";
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -78,17 +81,6 @@ void Problem12::reset(){
|
||||
counter = 2;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem12::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
results << "The triangular number " << sum << " is a sum of all numbers >= " << counter - 1 << " and has " << divisors.size() << " divisors";
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the triangular number
|
||||
int64_t Problem12::getTriangularNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user