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:
@@ -87,6 +87,13 @@ void Problem21::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "All amicable numbers less than 10000 are\n";
|
||||
for(unsigned int cnt = 0;cnt < amicable.size();++cnt){
|
||||
result << amicable.at(cnt) << '\n';
|
||||
}
|
||||
result << "The sum of all of these amicable numbers is " << mee::getSum(amicable);
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -99,22 +106,6 @@ void Problem21::reset(){
|
||||
reserveVectors();
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem21::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
results << "All amicable numbers less than 10000 are\n";
|
||||
for(unsigned int cnt = 0;cnt < amicable.size();++cnt){
|
||||
results << amicable.at(cnt) << '\n';
|
||||
}
|
||||
results << "The sum of all of these amicable numbers is " << mee::getSum(amicable);
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns a vector with all of the amicable numbers calculated
|
||||
std::vector<uint64_t> Problem21::getAmicable() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user