Advertisement
STANAANDREY

7/65

Nov 18th, 2019
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. typedef struct
  5. {
  6.     int num, numi;
  7. } FRAC;
  8.  
  9. int main()
  10. {
  11.     FRAC f[100];
  12.     int n;
  13.     cout << "n=";
  14.     cin >> n;
  15.     for (int i = 0; i < n; i++)
  16.         cin >> f[i].numi >> f[i].num;
  17.  
  18.     for (int i = 0; i < n; i++)
  19.     {
  20.         int a = f[i].numi, b = f[i].num, r;
  21.         while (b)
  22.         {
  23.             r = a % b;
  24.             a = b;
  25.             b = r;
  26.         }
  27.  
  28.         int cmmdc = a;
  29.         f[i].numi /= cmmdc;
  30.         f[i].num /= cmmdc;
  31.     }
  32.  
  33.     int cnt = 0;
  34.     for (int i = 0; i < n - 1; i++)
  35.         if (f[i].num == f[n - 1].num && f[i].numi == f[n - 1].numi)
  36.             cnt++;
  37.  
  38.     cout << cnt;
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement