Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;// ||
- int main() {
- unsigned long n,nr,i=1,d,eprim,S,aparitii;
- S=0;
- i=1;
- aparitii=0;
- cout<<"n=";cin>>n;
- while (i<=n)
- {
- d=2;
- eprim=1;
- cout<<"nr"<<i<<'=';cin>>nr;
- while (d<=nr/2&&eprim==1)
- {
- if (nr%d==0)
- eprim=0;
- d++;
- }
- if (eprim) {
- aparitii++;
- S+=nr;
- }
- i++;
- }
- long med=S/aparitii;
- cout<<"media nr prime e: "<<med;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement