mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-07 01:23:57 -05:00
Updated comments and made sure style was consistent
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
//ProjectEuler/C++/Headers/Problem9.hpp
|
||||
//ProjectEuler/ProjectEulerCPP/Headers/Problem9.hpp
|
||||
//Matthew Ellison
|
||||
// Created: 09-28-18
|
||||
//Modified: 07-14-19
|
||||
//Modified: 07-09-20
|
||||
//There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product of abc.
|
||||
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/myClasses
|
||||
/*
|
||||
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
|
||||
@@ -32,29 +32,30 @@
|
||||
|
||||
class Problem9 : public Problem{
|
||||
private:
|
||||
int a; //Holds the position on the first side
|
||||
int b; //Holds the position on the second side
|
||||
//Variables
|
||||
//Instance variables
|
||||
int a; //Holds the position on the first side
|
||||
int b; //Holds the position on the second side
|
||||
double c; //Holds the hyp
|
||||
bool found; //A flag to determine if we have found the solution yet
|
||||
public:
|
||||
//Constructor
|
||||
Problem9();
|
||||
virtual void solve();
|
||||
virtual std::string getString() const;
|
||||
virtual void reset();
|
||||
//Returns the length of the first side
|
||||
int getSideA() const;
|
||||
//Returns the length of the second side
|
||||
int getSideB() const;
|
||||
//Returns the length of the hyp
|
||||
int getSideC() const;
|
||||
//Returns the product of the 3 sides
|
||||
int getProduct() const;
|
||||
//Operational functions
|
||||
virtual void solve(); //Solve the problem
|
||||
virtual void reset(); //Reset the problem so it can be run again
|
||||
//Gets
|
||||
virtual std::string getString() const; //Return a string with the solution to the problem
|
||||
int getSideA() const; //Returns the length of the first side
|
||||
int getSideB() const; //Returns the length of the second side
|
||||
int getSideC() const; //Returns the length of the hyp
|
||||
int getProduct() const; //Returns the product of the 3 sides
|
||||
};
|
||||
|
||||
/* Results:
|
||||
The Pythagorean triplet is 200 375 425
|
||||
The numbers' product is 31875000
|
||||
It took 0.000 nanoseconds to solve this problem.
|
||||
It took an average of 154.595 microseconds to run this problem over 100 iterations
|
||||
*/
|
||||
|
||||
#endif //PROBLEM9_HPP
|
||||
|
||||
Reference in New Issue
Block a user