Advertisement
nicuvlad76

Untitled

Nov 20th, 2020
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.    int n , x,d,y;
  6.    bool ok;
  7.    cin>>n;
  8.    x=3;
  9.    while(n!=0)
  10.    {
  11.       ///x este prim
  12.       ok=1;///am presusp ca x este prim
  13.        for(d=3;d*d<=x && ok==1;d+=2)
  14.         if(x%d==0) ok=0;
  15.        if(ok==1)
  16.        {
  17.            y=x+2;
  18.            ///y este prim
  19.            ok=1;
  20.            for(d=3;d*d<=y && ok==1;d+=2)
  21.                 if(y%d==0) ok=0;
  22.            if(ok==1) {cout<<x<<' '<<y<<'\n'; n--;}
  23.        }
  24.        x+=2; ///trec la urmataoarea pereche de test
  25.    }
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement