#include <iostream>
#define _ std::
int main() {
int *a = new int[100];
int n, sum=0, c=0;
_ cin >> n;
for (int i = 0; i < n; i++) {
_ cin >> a[i];
if (a[i] < 0) {
sum += a[i];
c++;
}
_ cout << (c != 0 ? (double)sum / c : 0)<<_ endl;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
#include <iostream>
#define _ std::
int main() {
int *a = new int[100];
int n, sum=0, c=0;
_ cin >> n;
for (int i = 0; i < n; i++) {
_ cin >> a[i];
if (a[i] < 0) {
sum += a[i];
c++;
}
}
_ cout << (c != 0 ? (double)sum / c : 0)<<_ endl;
return 0;
}