Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
770 B
438
Indexable
Never
#include<iostream>   
#include<algorithm> 
#include<cmath> 
using namespace std; 
bool Check(long long int n){ 
	if(n < 2){ 
		return false;
	} 
	for(int i = 2; i <= sqrt(n); i++){  
		if(n % i == 0){ 
					return false;
		}
	} 
	return true;
} 
void Delete(long long int arr[100000], int n){   
	for(int i = 0; i < n; i++){ 
		for(int j = i + 1; j < n;){ 
			if(arr[i] == arr[j]){ 
				for(int k = j; k < n; k++){ 
					arr[k] = arr[k + 1];
				} 
				n--;
			}else{ 
				j++;
			}
		}
	} 
}
int main(){ 
	long long int n, arr[100000]; 
	cin >> n; 
	for(int i = 0; i < n; i++){ 
		cin >> arr[i];
	}    
	Delete(arr, n);
	sort(arr, arr+n); 
	for(int i = 0; i < n; i++){ 
		if(Check(arr[i])){ 
			cout << arr[i] << " ";
		}
	} 
}