Advertisement
KuriGohanAndKamehaX2

two functions

Nov 23rd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. bool is_simple(int a) // простое ли число
  2. {
  3. bool t = true;
  4.  
  5. if (a != 1)
  6. for (int i = 2; i < sqrt(a); i++)
  7. t &= !(a % i);
  8. else
  9. t = false;
  10.  
  11. return t;
  12. }
  13.  
  14. bool is_simple_el(int* a, int n) // есть ли в массиве простой элемент
  15. {
  16. bool t = false;
  17.  
  18. for (int i = 0; i < n; i++)
  19. t |= is_simple(a[i]);
  20.  
  21. return t;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement