Advertisement
kokusz19

2017.04.19.Primszam.fgv.proba

May 28th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. #include <stdlib.h>
  5. #include <math.h>
  6.  
  7. int prime(int *tomb, int db)
  8. {
  9. int i, j, primszam=1;
  10. for(i=0;i<db;i++)
  11. {
  12. if(tomb[i] < 2)
  13. {
  14. return 0;
  15. }
  16. for(j=2;j<=sqrt(tomb[i]);j++)
  17. {
  18. if(tomb[i]%j==0)
  19. {
  20. primszam = 0;
  21. }
  22. }
  23. if(primszam == 1)
  24. return 1;
  25. else
  26. return 0;
  27. }
  28. }
  29.  
  30. int main()
  31. {
  32. int db=5, i, j;
  33. int szamok[5] = {2, 3, 4, 5, 7};
  34.  
  35.  
  36.  
  37. printf(prime(szamok, db) ? "YES\n " : "NO\n");
  38.  
  39. return EXIT_SUCCESS;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement