Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int niza[n];
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- }
- double sum = 0.0;
- for(int i = 0; i < n; i++) {
- sum += niza[i];
- }
- sum /= n;
- double najbliska_razlika = 2000000000;
- int kukja;
- for(int i = 0; i < n; i++) {
- if(fabs(sum - niza[i]) < najbliska_razlika) {
- najbliska_razlika = fabs(sum - niza[i]);
- kukja = niza[i];
- }
- }
- cout << kukja << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement