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 (i % 2 == 0) {
- sum += a[i]; cnt++;
- }
- else if (ma < a[i]) ma = a[i];
- }
- cout << "TBC cac so o vi tri chan: " << sum / cnt << endl;
- cout << "So co GTLN o vi tri le: " << ma;
- }
Advertisement
Add Comment
Please, Sign In to add comment