Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,x,i,d;
- int ct, Max,Min;
- bool ok;
- cin>>n; ///nr de elemente
- ct=0;Max=-1;Min=1e9;
- for(int i=1;i<=n;i++)
- {
- cin>>x;///valoarea citita
- ok=1; /// am presuspus ca x este prim
- if(x<2) ok=0;
- else
- {
- for(d=2;d*d<=x && ok==1;d++)
- if(x%d==0)ok=0;
- }
- if(ok==1)
- {
- ct++;///numara cate sunt prime
- if(Max<x) Max=x;
- if(Min>x) Min=x;
- }
- }
- cout<<ct<<' '<<Min<<' '<<Max;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement