📅  最后修改于: 2022-03-11 15:00:47.195000             🧑  作者: Mango
#include
using namespace std;
void input(int arr[], int n)
{
for (int i = 0; i < n; i++)
{
cout << "Enter Number #" << i + 1 << " :";
cin >> arr[i];
while (arr[i] % 2 == 0) //check array[i] even or odd.
{
cout << "Invalid!" << endl;
cout << "please, Enter number #" << i + 1 << " :";
cin >> arr[i];
}
}
}
int main()
{
const int n = 5;
int arr[n];
input(arr, n);
for (int i = 0; i < n; i++)
{
cout << arr[i] << " ";
}
return 0;
}