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:
@@ -65,6 +65,10 @@ void Problem16::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << NUM_TO_POWER << '^' << POWER << " = " << num
|
||||
<< "\nThe sum of the elements is " << sumOfElements;
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -76,20 +80,6 @@ void Problem16::reset(){
|
||||
sumOfElements = 0;
|
||||
}
|
||||
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem16::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
results << NUM_TO_POWER << '^' << POWER << " = " << num
|
||||
<< "\nThe sum of the elements is " << sumOfElements;
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the number that was calculated
|
||||
mpz_class Problem16::getNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user