Updated comments and made sure style was consistent

This commit is contained in:
2020-07-10 13:36:16 -04:00
parent 7257a118d4
commit c72754dcf8
65 changed files with 1160 additions and 747 deletions

View File

@@ -1,14 +1,14 @@
//ProjectEuler/C++/Source/Problem20.cpp
//ProjectEuler/ProjectEulerCPP/Source/Problem20.cpp
//Matthew Ellison
// Created: 11-07-18
//Modified: 07-14-19
//Modified: 07-09-20
//What is the sum of the digits of 100!?
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/myClasses
//This file contains a header from the gmp library. The library is used for large integers.
//You can find more information about them at https://gmplib.org/
//When compiling this file you need to have the gmp library installed as well as linking the libraries to your executable using the -lgmpxx and -lgmp flags
/*
Copyright (C) 2019 Matthew Ellison
Copyright (C) 2020 Matthew Ellison
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -33,11 +33,13 @@
#include "../Headers/Problem20.hpp"
//Constructor
Problem20::Problem20() : Problem("What is the sum of the digits of 100!?"), num(1), sum(0){
//num Starts at 1 because multiplication is performed on it
//sum starts at 0 because addition is performed on it
}
//Solve the problem
void Problem20::solve(){
//If the problem has already been solved do nothing and end the function
if(solved){
@@ -66,6 +68,14 @@ void Problem20::solve(){
solved = true;
}
//Reset the problem so it can be run again
void Problem20::reset(){
Problem::reset();
sum = 0;
num = 1;
}
//Return a string with the solution to the problem
std::string Problem20::getString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -78,6 +88,7 @@ std::string Problem20::getString() const{
return results.str();
}
//Returns the number 100!
mpz_class Problem20::getNumber() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -86,6 +97,7 @@ mpz_class Problem20::getNumber() const{
return num;
}
//Returns the number 100! in a string
std::string Problem20::getNumberString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -94,6 +106,7 @@ std::string Problem20::getNumberString() const{
return num.get_str();
}
//Returns the sum of the digits of 100!
uint64_t Problem20::getSum() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -101,9 +114,3 @@ uint64_t Problem20::getSum() const{
}
return sum;
}
void Problem20::reset(){
Problem::reset();
sum = 0;
num = 1;
}