Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- int n, x, nrn=0;
- float s=0;
- cin >> n;
- for(int i=1; i<=n; ++i)
- {
- cin >> x;
- bool prim=true;
- if(x<2) prim=false;
- else
- if(x==2) prim=true;
- else
- if(x%2==0) prim=false;
- else
- for(int j=3; j*j<=x; j=j+2)
- if(x%i==0) prim=false;
- if(prim==true)
- {
- s=s+x;
- nrn++;
- }
- }
- float med=s/nrn;
- if(med==0) cout << "NU EXISTA";
- else
- cout << setprecision(3) << med;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement