Advertisement
Guest User

Untitled

a guest
May 26th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. int main(void)
  7. {
  8. int n;
  9. int k=0;
  10. cin>>n;
  11. double p = 0;
  12. double *x = (double *)malloc(n*sizeof(double));
  13. for(int i=0;i<n;i++)
  14. {
  15. cin>>x[i];
  16. if (x[i]<0)
  17. {
  18. p+=x[i];
  19. k++;
  20. }
  21. }
  22. p/=k;
  23. cout<<p;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement