diff --git "a/Programmers/\353\266\204\354\210\230\354\235\230_\353\215\247\354\205\210.cpp" "b/Programmers/\353\266\204\354\210\230\354\235\230_\353\215\247\354\205\210.cpp" new file mode 100644 index 0000000..b0a3fa1 --- /dev/null +++ "b/Programmers/\353\266\204\354\210\230\354\235\230_\353\215\247\354\205\210.cpp" @@ -0,0 +1,25 @@ +#include +#include +#include + +using namespace std; + +int gcd(int a, int b) { + while (b != 0) { + int temp = a % b; + a = b; + b = temp; + } + return a; +} + +vector solution(int numer1, int denom1, int numer2, int denom2) { + int numerator = numer1 * denom2 + numer2 * denom1; + int denominator = denom1 * denom2; + + int common = gcd(numerator, denominator); + numerator /= common; + denominator /= common; + + return {numerator, denominator}; +} \ No newline at end of file