Concetti Chiave
- This C++ program is designed to handle an array of up to 100 elements and categorize them based on their position being even or odd.
- The function "Dimensionamento()" prompts the user to input the size of the array, ensuring it's within the maximum defined limit.
- "CaricaVettore()" is responsible for populating the array with user-input values.
- Separate functions "StampaPari()" and "StampaDispari()" print elements located at even and odd positions respectively.
- The main function orchestrates the process by calling these functions in sequence, managing user interaction and display.
//Dato un vettore di n elementi crearne:
//uno con gli elementi di posto pari
//e uno con gli elementi di posto dispari
#include
using namespace std;
const int MAX=100;
int Dimensionamento();
int CaricaVettore(int v[MAX], int d);
void Stampa_Vett_Principale(int v[], int d);
void StampaPari(int v[], int d);
void StampaDispari(int v[], int d);
int Dimensionamento()
{
int d;
do{
cout
cin>>d;
} while (dMAX);
return d;
}
int CaricaVettore(int v[MAX], int d)
{
for (int i=0; i
}
}
void Stampa_Vett_Principale(int v[], int d)
{
cout
while (d>=0){
cout
d--;
}
}
void StampaPari(int v[], int d)
{
cout
do{
if (d%2==0){
cout
}
d--;
} while (d>=0);
}
void StampaDispari(int v[], int d)
{
cout
do{
if (d%2!=0){
cout
}
d--;
} while (d>=0);
}
int main()
{
int d, v[100];
d=Dimensionamento();
cout
CaricaVettore(v,d);
Stampa_Vett_Principale(v,d);
StampaPari(v,d);
StampaDispari(v,d);
system("pause");
return 0;
}