tuki2501

b3.cpp

Mar 12th, 2021
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.   int n, cnt = 0;
  6.   double a[50], sum = 0;
  7.   cout << "Nhap n: "; cin >> n;
  8.   for (int i = 0; i < n; i++) {
  9.     cout << "Nhap a[" << i << "]: "; cin >> a[i];
  10.     if (a[i] > 0) {
  11.       sum += a[i];
  12.       cnt++;
  13.     }
  14.   }
  15.   cout << "TBC cac phan tu duong la: " << sum / cnt << endl;
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment