Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- int i, k=0;
- double x[30], y[30], s=0, r;
- setlocale(0,"rus");
- for (i=0;i<30;i++)
- {
- x[i]=-100+rand()%200;
- x[i]=x[i]/4;
- }
- for (i=0; i<30;i++)
- {
- cout<<"X["<<i+1<<"]= "<<x[i]<<endl;
- }
- for (i=0;i<30;i++)
- {
- if (x[i]>0)
- {
- y[k]=x[i];
- k=k+1;
- s=s+x[i];
- }
- }
- cout<<endl;
- for (i=0;i<k;i++)
- {
- cout<<"Y["<<i+1<<"]= "<<y[i]<<endl;
- }
- r=s/k;
- cout<<"Среднее арифмитическое элементов массива Y= "<<r<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement