Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n, cnt = 0;
- float a[100], sum = 0, ma = INT_MIN;
- cout << "Nhap n: "; cin >> n;
- for (int i = 0; i < n; i++) {
- cout << "Nhap a[" << i << "]: "; cin >> a[i];
- if (a[i] > 0) {
- sum += a[i]; cnt++;
- }
- if (a[i] < 0) if (ma < a[i]) ma = a[i];
- }
- if (cnt == 0) cout << "Khong co so duong" << endl;
- else cout << "TBC cac so duong: " << sum / cnt << endl;
- if (ma == INT_MIN) cout << "Khong co so am";
- else cout << "So am co GTLN: " << ma;
- }
Advertisement
Add Comment
Please, Sign In to add comment