#include <iostream> #include <ctime> using namespace std; int main () { const int N=10; int mass[N]; int x,sum=0; srand (time(NULL)); for (int i=0;i<N;i++) { x=rand()%50; cout << x << ' '; mass[i]=x; } if (N%2!=0) { mass[N-1]=0; } for (int i=0;i<N-1;i+=2) sum+=mass[i]*mass[i+1]; cout << endl << sum; system ("PAUSE>>VOID"); return 0; }
#include <ctime>
using namespace std;
int main ()
{
const int N=10;
int mass[N];
int x,sum=0;
srand (time(NULL));
for (int i=0;i<N;i++)
{
x=rand()%50;
cout << x << ' ';
mass[i]=x;
}
if (N%2!=0)
{
mass[N-1]=0;
}
for (int i=0;i<N-1;i+=2)
sum+=mass[i]*mass[i+1];
cout << endl << sum;
system ("PAUSE>>VOID");
return 0;
}