Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #define T long long
- T gcd(T a, T b);
- int main()
- {
- // Simple file reading(std::ios_base::in - говорит, что мы читаем)
- std::ifstream input("gcd.in", std::ios_base::in);
- // Simple file writing(std::ios_base::out - говорит, что мы читаем)(std::ios_base::trunc - говорит о перезаписи файла)
- std::ofstream output("gcd.out", std::ios_base::out | std::ios_base::trunc);
- T a, b;
- input >> a;
- input >> b;
- output << gcd(a, b);
- return 0;
- }
- T gcd(T a, T b)
- {
- if (b == 0)
- return a;
- else
- return gcd(b, a % b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement