mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-24 18:43:17 +08:00
formatting source-code for d7af6fdc8c
This commit is contained in:
@@ -11,12 +11,15 @@
|
||||
/**
|
||||
* algorithm
|
||||
*/
|
||||
int gcd(int num1, int num2) {
|
||||
if (num1 <= 0 | num2 <= 0) {
|
||||
int gcd(int num1, int num2)
|
||||
{
|
||||
if (num1 <= 0 | num2 <= 0)
|
||||
{
|
||||
throw std::domain_error("Euclidean algorithm domain is for ints > 0");
|
||||
}
|
||||
|
||||
if (num1 == num2) {
|
||||
if (num1 == num2)
|
||||
{
|
||||
return num1;
|
||||
}
|
||||
|
||||
@@ -39,11 +42,15 @@ int gcd(int num1, int num2) {
|
||||
/**
|
||||
* Main function
|
||||
*/
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
std::cout << "gcd of 120,7 is " << (gcd(120, 7)) << std::endl;
|
||||
try {
|
||||
try
|
||||
{
|
||||
std::cout << "gcd of -120,10 is " << gcd(-120, 10) << std::endl;
|
||||
} catch (const std::domain_error &e) {
|
||||
}
|
||||
catch (const std::domain_error &e)
|
||||
{
|
||||
std::cout << "Error handling was successful" << std::endl;
|
||||
}
|
||||
std::cout << "gcd of 312,221 is " << (gcd(312, 221)) << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user