tuki2501

de_2.cpp

Feb 4th, 2021
907
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.   int n, a[50], odd = 0, sum = 0, cnt = 0;
  6.   cout << "Nhap n: "; cin >> n;
  7.   for (int i = 0; i < n; i++) {
  8.     cout << "Nhap a[" << i << "]: "; cin >> a[i];
  9.     if (a[i] % 2 == 1) odd++;
  10.     if (a[i] % 6 == 0) {
  11.       sum += a[i]; cnt++;
  12.     }
  13.   }
  14.   cout << "So so le: " << odd << endl;
  15.   if (cnt == 0) cout << "Khong chua so le boi 3";
  16.   else cout << "TBC cac so le boi 3: " << (float) sum / cnt;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment