Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, a, contor = 0; //n = cate numere vrei sa testam
- // contor = cate numere sunt divizibile cu 7
- int medie_aritmetica, suma = 0;
- cout << "Introdu n: "; cin >> n;
- for (int i = 0; i < n; i++) // repetam de n ori
- {
- cout << "Introdu a: "; cin >> a;
- if (a % 7 == 0) //verificam daca nr. introdus este divizibil cu 7
- {
- suma += a;
- contor++; // contor = contor + 1
- }
- }
- medie_aritmetica = suma / contor; //formula matematica pt media aritmetica
- cout << "Media: " << medie_aritmetica << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment