aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk3/lab3/gcd.cpp
diff options
context:
space:
mode:
authorMatthew Strapp <msattr@gmail.com>2019-02-21 08:56:55 -0600
committerMatthew Strapp <msattr@gmail.com>2019-02-21 08:56:55 -0600
commit2b81e1c3095b8177b726c5a00b94af1270c3efe0 (patch)
tree7e265248c616da60b9080092b6e8204156da29ba /ee1301/wk3/lab3/gcd.cpp
parentFinish Lab 3 (diff)
downloadhomework-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.cpp25
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;
+}