#include <iostream>
#include <string>
#include <ctime>
using namespace std;
const int n = 5;
const int m = 5;
int x[n];
int y[m];
void x_init()
{
for (int i = 0; i < n; i++)
x[i] = rand() % 10;
}
void x_show()
cout << "x[n] array: ";
cout << x[i] << " ";
cout << endl;
int x_sum()
int sum = 0;
if (x[i] % 2 == 0) sum += x[i];
return sum;
void y_init()
for (int i = 0; i < m; i++)
y[i] = rand() % 10;
void y_show()
cout << "y[m] array: ";
cout << y[i] << " ";
int y_sum()
if (y[i] % 2 == 0) sum += y[i];
int main()
string result;
srand(time(NULL));
x_init();
x_show();
y_init();
y_show();
x_sum() > y_sum() ? result = "<x[n] array!>" : result = "<y[m] array!>";
cout << "sum of paired elements in x[n] array: " << x_sum() << endl;
cout << "sum of paired elements in y[m] array: " << y_sum() << endl;
cout << "the sum of paired elements is greater in the " << result << endl;
return 0;
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
const int n = 5;
const int m = 5;
int x[n];
int y[m];
void x_init()
{
for (int i = 0; i < n; i++)
{
x[i] = rand() % 10;
}
}
void x_show()
{
cout << "x[n] array: ";
for (int i = 0; i < n; i++)
{
cout << x[i] << " ";
}
cout << endl;
}
int x_sum()
{
int sum = 0;
for (int i = 0; i < n; i++)
{
if (x[i] % 2 == 0) sum += x[i];
}
return sum;
}
void y_init()
{
for (int i = 0; i < m; i++)
{
y[i] = rand() % 10;
}
}
void y_show()
{
cout << "y[m] array: ";
for (int i = 0; i < m; i++)
{
cout << y[i] << " ";
}
cout << endl;
}
int y_sum()
{
int sum = 0;
for (int i = 0; i < m; i++)
{
if (y[i] % 2 == 0) sum += y[i];
}
return sum;
}
int main()
{
string result;
srand(time(NULL));
x_init();
x_show();
y_init();
y_show();
x_sum() > y_sum() ? result = "<x[n] array!>" : result = "<y[m] array!>";
cout << "sum of paired elements in x[n] array: " << x_sum() << endl;
cout << "sum of paired elements in y[m] array: " << y_sum() << endl;
cout << "the sum of paired elements is greater in the " << result << endl;
return 0;
}