Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int f(int n){
  6. if (n<2) return 0;
  7. for(int i=2; i<=sqrt(n); i++)
  8. {
  9. if(n%i==0) return 0;
  10. }
  11. return 1;
  12. }
  13.  
  14.  
  15.  
  16.  
  17. int main(){
  18.  
  19.  
  20.  
  21. int n, i;
  22. cin>>n;
  23. int a[n];
  24. for (i=0; i<n; i++){
  25. cin>>a[i];
  26. }
  27. for (i=0; i<n; i++){
  28. if (f(a[i])==1){
  29. a[i]=1;
  30. }
  31. else {
  32. a[i]=0;
  33. }
  34. }
  35. for (int i=0; i<n; i++){
  36. cout<<a[i]<<" ";
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement