Advertisement
Guest User

Untitled

a guest
Aug 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int prim(int a)
  5. {
  6. int b,c = 0;
  7. for(b = 2;b <= a;b++)
  8. {
  9. if(a % b == 0)
  10. {
  11. c++;
  12. }
  13. if(c > 1)
  14. a = 1;
  15. else
  16. a = 0;
  17. }
  18. return a;
  19. }
  20.  
  21.  
  22.  
  23. int main()
  24. {
  25. int A[100][100],i,j,m,n;
  26. int sum = 0;
  27.  
  28. cin>>m>>n;
  29.  
  30. for(i = 0; i < m;i++)
  31. for(j = 0; j < n;j++)
  32. {
  33. cin>> A[i][j];
  34. }
  35.  
  36.  
  37. for(i = 0; i < m; i++)
  38. for(j = 0;j < n; j++)
  39. {
  40. sum = sum + prim(A[i][j]);
  41. }
  42. cout<<sum;
  43.  
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement