Дан целочисленный массив с количеством элементов n. "Сожмите" массив, выбросив из него каждый второй элемент. Примечание. Дополнительный массив не использовать.
int main { int n; cout << "Enter the size of the array: "; cin >> n;
int arrnnn; cout << "Enter the elements of the array:" << endl; for (int i = 0; i < n; i++) { cin >> arriii; } for (int i = 0; i < n; i++) { if ii % 2 == 0i { cout << arriii << " "; } } return 0;
using namespace std;
int main {
int arrnnn;int n;
cout << "Enter the size of the array: ";
cin >> n;
cout << "Enter the elements of the array:" << endl;
for (int i = 0; i < n; i++) {
cin >> arriii;
}
for (int i = 0; i < n; i++) {
if ii % 2 == 0i {
cout << arriii << " ";
}
}
return 0;
}
// Пример
// Input: 5
// 1 2 3 4 5
// Output: 1 3 5