Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- typedef struct
- {
- int num, numi;
- } FRAC;
- int main()
- {
- FRAC f[100];
- int n;
- cout << "n=";
- cin >> n;
- for (int i = 0; i < n; i++)
- cin >> f[i].numi >> f[i].num;
- for (int i = 0; i < n; i++)
- {
- int a = f[i].numi, b = f[i].num, r;
- while (b)
- {
- r = a % b;
- a = b;
- b = r;
- }
- int cmmdc = a;
- f[i].numi /= cmmdc;
- f[i].num /= cmmdc;
- }
- int cnt = 0;
- for (int i = 0; i < n - 1; i++)
- if (f[i].num == f[n - 1].num && f[i].numi == f[n - 1].numi)
- cnt++;
- cout << cnt;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement