Не совсем понятно условие, но вот возможное решение в C++
#include
#include
#include
int main()
{
using namespace std;
cout << "Enter N: ";<br> int N;
cin >> N;
int * A = new int[N];
srand(time(0));
for (int i = 0; i < N; ++i)
A[i] = rand() % N + 1;
for (int i = 0; i < N; ++i)
cout << setw(4) << A[i];<br>
cout << "\nEnter K: ";<br> int K;
cin >> K;
int SIZE = 0;
for (int i = 0; i < N; ++i)
if (A[i] <= K)<br> ++SIZE;
if (SIZE > 0)
{
int * A1 = new int[SIZE];
int i1 = 0;
for (int i = 0; i < N; ++i)
if (A[i] <= K)<br> {
A1[i1] = A[i];
++i1;
}
for (int i1 = 0; i1 < SIZE; ++i1)
cout << setw(4) << A1[i1];<br> delete[] A1;
}
else
cout << "No elements" << endl;<br> delete[] A;
cout << endl;<br> return 0;
}