Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- void cmmdc(unsigned a, unsigned b, unsigned& dc)
- {
- while (a != b)
- if (a > b)
- a -= b;
- else
- b -= a;
- dc = a;
- }
- void simplif(unsigned& x, unsigned& y)
- {
- unsigned z;
- cmmdc(x, y, z);
- x /= z;
- y /= z;
- }
- int main()
- {
- ifstream f("FR.IN");
- ofstream g("FR.OUT");
- unsigned x, y;
- while (f >> x >> y)
- {
- simplif(x, y);
- g << x << ' ' << y << endl;
- }
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement