👤

Se citesc de la tastatura n valori intregi.Sa se scrie un algoritm care calzuleze media valorilor impare pozitive.
Nu stiu sa rezolv acest ex ,l am vazut intr o culegere pt cls a 9 a


Răspuns :

#include <bits/stdc++.h>
using namespace std;
int main(){    int n, s = 0, ct = 0, x;    float o;    cin >> n;    for(int i = 1; i <= n; i++)        {            cin >> x;            if(x > 0 && x % 2 == 1)            {                s = s + x;                ct++;            }        }        if(ct)        {            o = (float) s / ct;            o = o * 100;            s = (int) o;            cout << fixed << setprecision(2) << (float) s / 100;        }        else cout << "NU ARE NUMERE IMPARE";   return 0;}