tuki2501

b1.cpp

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