int main() { int n=10, i, s=0; int a[n]; srand(time(NULL)); cout<<"array:"<<endl; for (i=0; i<n; i++) { a[i]=rand() % 50; cout<<a[i]<<" "; } cout<<endl; i = 1; do { a[i] = a[i]*a[i]; s += a[i]; i += 2; } while (i<=n);
for (i=0; i<n; i++) cout<<a[i]<<" "; cout<<endl; cout << "s = " << s << endl; return(0); }
#include <cstdlib>#include <ctime>
using namespace std;
int main() {
srand(time(0));
const int n = 5;
int x[n], y[n], x0=0, y0=0;
for (int i = 0; i < n; ++i) {
x[i] = rand() % 5;
y[i] = rand() % 5;}
for (int i = 0; i < n; ++i) {
cout<< x[i]<<' ';}
cout << endl;
for (int i = 0; i < n; ++i) {cout << y[i] << ' ';}
for (int i = 0; i < n; ++i) {
if (x[i]) x0++;
if (y[i]) y0++;}
cout << endl;
if (x0 > y0) cout << 'x';
if (x0 < y0) cout << 'y';
if (x0 == y0) cout << '=';
return 0;}