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:
@@ -89,6 +89,10 @@ void Problem26::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "The longest cycle is " << longestCycle << " digits long\n"
|
||||
<< "It is started with the number " << longestNumber;
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -100,20 +104,6 @@ void Problem26::reset(){
|
||||
longestNumber = 1;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem26::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
results << "The longest cycle is " << longestCycle << " digits long\n"
|
||||
<< "It is started with the number " << longestNumber;
|
||||
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the length of the longest cycle
|
||||
unsigned int Problem26::getLongestCycle() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user