fork download
  1. #include <iostream>
  2. using namespace std;
  3. bool yes(int a){
  4. for(int i=2;i<a;i++){
  5. if (a%i==0)return false;
  6. }
  7. return true;
  8. }
  9. int main() {
  10. int n;
  11. cin>> n;
  12. int* a= new int[n];
  13. for(int i =0;i<n;i++){
  14. cin>>a[i];
  15. }
  16. int p=n-1;
  17. for(int i=0;i<p;i++){
  18. if(yes(a[i])){
  19. int t=a[i];
  20. for(int j=i;j<p;j++){
  21. a[j]=a[j+1];
  22. }
  23. a[p]=t;
  24. p--;
  25. i--;
  26.  
  27. }
  28. }
  29. for(int i=0;i<n;i++){
  30. cout<<a[i];
  31. }
  32. delete[] a;
  33. return 0;
  34. }
Success #stdin #stdout 0s 5292KB
stdin
7
13
8
9
17
82
2
50
stdout
89825021713