Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream f("date.in");
- ifstream ff("date2.in");
- ofstream g("date.out");
- int cmmdc (int a, int b)
- {
- while (a != b)
- {
- if (a > b)
- {
- a = a - b;
- }
- else
- {
- b = b - a;
- }
- }
- return a;
- }
- int main()
- {
- int v[100],a[100],i,j,n;
- f>>n;
- for (i=1;i<=n;i++)
- f>>v[i];
- for (j=1;j<=n;j++)
- ff>>a[j];
- for (i=1;i<=n;i++)
- for (j=1;j<=n;j++)
- if ( cmmdc (v[i],a[j]) == 1)
- g<<v[i]<<" "<<a[j]<<" ";
- }
Add Comment
Please, Sign In to add comment