tuki2501

one.cpp

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