LabiinfaCibGyti

laba6.13

Dec 11th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6. int _tmain(int argc, _TCHAR* argv[])
  7. {
  8. int i;
  9. double a[20], s=0, max=-300000,r;
  10. setlocale(0, "rus");
  11. for (i=0;i<20;i++)
  12. {
  13.     a[i]=-10.5+rand()%20;
  14. }
  15. for (i=0;i<20;i++)
  16. {
  17.     cout<<"A["<<i+1<<"]= "<<a[i]<<endl;
  18.     s=s+a[i];
  19.     if (a[i]>max && a[i]<0)
  20.         max=a[i];
  21. }
  22. r=s/20;
  23. cout<<"Среднее арифмитическое= "<<r<<"\tМаксимальный отрицательный элемент = "<<max<<endl;
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment