Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main(void)
- {
- int n;
- int k=0;
- cin>>n;
- double p = 0;
- double *x = (double *)malloc(n*sizeof(double));
- for(int i=0;i<n;i++)
- {
- cin>>x[i];
- if (x[i]<0)
- {
- p+=x[i];
- k++;
- }
- }
- p/=k;
- cout<<p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement