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:
@@ -58,6 +58,9 @@ void Problem6::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "The difference between the sum of the squares and the square of the sum of all numbers from 1-100 is " << abs(sumOfSquares - squareOfSum);
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -68,17 +71,6 @@ void Problem6::reset(){
|
||||
sumOfSquares = squareOfSum = 0;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem6::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
results << "The difference between the sum of the squares and the square of the sum of all numbers from 1-100 is " << abs(sumOfSquares - squareOfSum);
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the sum of all the squares
|
||||
uint64_t Problem6::getSumOfSquares() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user