Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. bool f(int n, int m)
  7. {
  8. if (n==1)
  9. return 0;
  10. for (int i=2;i<n;i++)
  11. {
  12. for (int j=2;j<m;j++)
  13. if (n%i==0 && m%j==0)
  14. return 0;
  15. }
  16.  
  17. return 1;
  18. }
  19. void main ()
  20. {
  21. int i,j,n,m,a[50][50],k;
  22. cout<<"Vv. n i m: ";
  23. cin>>n>>m;
  24. k=0;
  25. cout<<"Vv. elemety: ";
  26. for (i=0;i<n;i++)
  27. for (j=0;j<m;j++)
  28. cin>>a[i][j];
  29. for (i=0;i<n;i++)
  30. {
  31. for (j=0;j<m;j++)
  32. if (f(i,j))
  33. k++;
  34. }
  35. cout<<"K= "<<k;
  36. getch ();
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement