alex326

Untitled

Apr 16th, 2018
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. problema 510
  2.  
  3. #include <iostream>
  4. using namespace std;
  5. int main()
  6. {
  7. long long v[1000],n,i,j,c,d=2,ok=0;
  8. cin>>n;
  9. for (i=1;i<=n;i++)
  10. cin>>v[i];
  11. for (i=1;i<=n;i++){
  12. d=2;
  13. ok=0;
  14. while (d*d<=v[i] && ok==0){
  15. if (v[i]%d==0)
  16. ok=1;
  17. d++;
  18. }
  19. if (v[i]==0 || v[i]==1)
  20. ok=1;
  21. if (ok==1){
  22. for (j=i;j<n;j++)
  23. v[j]=v[j+1];
  24. n--;
  25. i--;
  26. }
  27. }
  28. for (i=1;i<=n;i++){
  29. for (j=i+1;j<=n;j++)
  30. if (v[i]>v[j]){
  31. c=v[i];
  32. v[i]=v[j];
  33. v[j]=c;
  34. }
  35. }
  36. for (i=1;i<=n;i++)
  37. cout<<v[i]<<' ';
  38. }
Add Comment
Please, Sign In to add comment