Robert_Manea

nr prime in matrici

Dec 9th, 2019
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int n,m,j,i,a[20][20],nr=0,s,d;
  7. printf("n=");
  8. scanf("%d",&n);
  9. printf("m=");
  10. scanf("%d",&m);
  11. for(i=0;i<n;i++)
  12. for(j=0;j<m;j++){
  13. printf("a[%d][%d]",i,j);
  14. scanf("%d",&a[i][j]);
  15. }
  16. for(i=0;i<n;i++)
  17. for(j=0;j<m;j++){
  18. s=0;
  19. for(d=1;d<=a[i][j]/2;d++)
  20. if(a[i][j]%d==0)
  21. s+=d;
  22.  
  23. if(a[i][j]==s)
  24. nr++;
  25. }
  26. printf("%d",nr);
  27. return 0;
  28. }
RAW Paste Data