Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int a[50], n, k, sum = 0, cnt = 0;
- cout << "Nhap n, k: "; cin >> n >> k;
- for (int i = 0; i < n; i++) {
- cout << "Nhap a[" << i << "]: "; cin >> a[i];
- if (a[i] % k == 0) {
- sum += a[i];
- cnt++;
- }
- }
- cout << "TBC cac phan tu chia het cho K la: " << (double) sum / cnt << endl;
- }
Add Comment
Please, Sign In to add comment