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:
@@ -64,6 +64,10 @@ void Problem20::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "100! = " << num.get_str()
|
||||
<< "\nThe sum of the digits is: " << sum;
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -75,19 +79,6 @@ void Problem20::reset(){
|
||||
num = 1;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem20::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
//Print the results
|
||||
results << "100! = " << num.get_str()
|
||||
<< "\nThe sum of the digits is: " << sum;
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the number 100!
|
||||
mpz_class Problem20::getNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user