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;
- double a[20], s=0, max=-300000,r;
- setlocale(0, "rus");
- for (i=0;i<20;i++)
- {
- a[i]=-10.5+rand()%20;
- }
- for (i=0;i<20;i++)
- {
- cout<<"A["<<i+1<<"]= "<<a[i]<<endl;
- s=s+a[i];
- if (a[i]>max && a[i]<0)
- max=a[i];
- }
- r=s/20;
- cout<<"Среднее арифмитическое= "<<r<<"\tМаксимальный отрицательный элемент = "<<max<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment