#include <iostream>
using namespace std;
int main() {
long n, a, b;
cout << "Cit de mare va fi vectorul? ";
cin >> n;
long double vector[n];
cout << "Introdu numerele:\n";
for (int i = 0; i < n; i++) {
cin >> vector[i];
}
cout << "De unde pina unde vrei sa afli media? (indexuri a si b): ";
cin >> a >> b;
if (a < 0 || b >= n || a > b) {
cout << "Interval invalid!";
return 0;
}
long double suma = 0;
long contor = 0;
for (int i = a; i <= b; i++) {
suma += vector[i];
contor++;
}
cout << "Media numerelor este: " << (suma / contor);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBsb25nIG4sIGEsIGI7CiAgICBjb3V0IDw8ICJDaXQgZGUgbWFyZSB2YSBmaSB2ZWN0b3J1bD8gIjsKICAgIGNpbiA+PiBuOwoKICAgIGxvbmcgZG91YmxlIHZlY3RvcltuXTsKCiAgICBjb3V0IDw8ICJJbnRyb2R1IG51bWVyZWxlOlxuIjsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgY2luID4+IHZlY3RvcltpXTsKICAgIH0KCiAgICBjb3V0IDw8ICJEZSB1bmRlIHBpbmEgdW5kZSB2cmVpIHNhIGFmbGkgbWVkaWE/IChpbmRleHVyaSBhIHNpIGIpOiAiOwogICAgY2luID4+IGEgPj4gYjsKICAgIGlmIChhIDwgMCB8fCBiID49IG4gfHwgYSA+IGIpIHsKICAgIGNvdXQgPDwgIkludGVydmFsIGludmFsaWQhIjsKICAgIHJldHVybiAwOwp9CgoKICAgIGxvbmcgZG91YmxlIHN1bWEgPSAwOwogICAgbG9uZyBjb250b3IgPSAwOwoKICAgIGZvciAoaW50IGkgPSBhOyBpIDw9IGI7IGkrKykgewogICAgICAgIHN1bWEgKz0gdmVjdG9yW2ldOwogICAgICAgIGNvbnRvcisrOwogICAgfQoKICAgIGNvdXQgPDwgIk1lZGlhIG51bWVyZWxvciBlc3RlOiAiIDw8IChzdW1hIC8gY29udG9yKTsKCiAgICByZXR1cm4gMDsKfQoK