diff options
author | Matthew Strapp <msattr@gmail.com> | 2019-02-21 08:56:55 -0600 |
---|---|---|
committer | Matthew Strapp <msattr@gmail.com> | 2019-02-21 08:56:55 -0600 |
commit | 2b81e1c3095b8177b726c5a00b94af1270c3efe0 (patch) | |
tree | 7e265248c616da60b9080092b6e8204156da29ba /ee1301/wk3/lab3/gcd.cpp | |
parent | Finish Lab 3 (diff) | |
download | homework-2b81e1c3095b8177b726c5a00b94af1270c3efe0.tar homework-2b81e1c3095b8177b726c5a00b94af1270c3efe0.tar.gz homework-2b81e1c3095b8177b726c5a00b94af1270c3efe0.tar.bz2 homework-2b81e1c3095b8177b726c5a00b94af1270c3efe0.tar.lz homework-2b81e1c3095b8177b726c5a00b94af1270c3efe0.tar.xz homework-2b81e1c3095b8177b726c5a00b94af1270c3efe0.tar.zst homework-2b81e1c3095b8177b726c5a00b94af1270c3efe0.zip |
Forget to commit things
Diffstat (limited to 'ee1301/wk3/lab3/gcd.cpp')
-rw-r--r-- | ee1301/wk3/lab3/gcd.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ee1301/wk3/lab3/gcd.cpp b/ee1301/wk3/lab3/gcd.cpp new file mode 100644 index 0000000..435fd07 --- /dev/null +++ b/ee1301/wk3/lab3/gcd.cpp @@ -0,0 +1,25 @@ +#include <iostream> +#include <cmath> +using namespace std; + +int GCD(int a, int b) { + int gcd=0; + a=abs(a); b=abs(b); + if (a>b) { + //do nothing + } else { + if (b>a) { + int foo=a; a=b; b=foo; + } else { + return 1; + } + } + gcd=(a/b)+(a%b); + return gcd; +} +int main () { + int a=0, b=0; + cout << "Enter two integers: "; + cin >> a, b; + cout << GCD(a,b) << endl; +} |