Advertisement
catalyn

subpr cmmdc n perechi

Oct 2nd, 2014
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5. ifstream f("date.in");
  6. ifstream ff("date2.in");
  7. ofstream g("date.out");
  8.  
  9. int cmmdc (int a, int b)
  10. {
  11. while (a != b)
  12. {
  13. if (a > b)
  14. {
  15. a = a - b;
  16. }
  17. else
  18. {
  19. b = b - a;
  20. }
  21. }
  22. return a;
  23. }
  24.  
  25. int main()
  26. {
  27. int v[100],i,j,n;
  28. f>>n;
  29. for (i=1;i<=n;i++)
  30. f>>v[i];
  31.  
  32.  
  33. for (i=1;i<=n;i++)
  34. for (j=1;j<=n;j++)
  35. if ( cmmdc (v[i],v[j]) == 1)
  36. g<<v[i]<<" "<<v[j]<<" ";
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement