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:
@@ -54,6 +54,9 @@ void Problem7::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "The " << NUMBER_OF_PRIMES << "th prime number is " << primes.at(primes.size() - 1);
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -63,17 +66,6 @@ void Problem7::reset(){
|
||||
Problem::reset();
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem7::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
results << "The " << NUMBER_OF_PRIMES << "th prime number is " << primes.at(primes.size() - 1);
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the requested prime number
|
||||
uint64_t Problem7::getPrime() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user