Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int c[10000000],A[1000];
- void csere(int &a, int &b)
- {
- int s=a;
- a=b;
- b=s;
- }
- int main()
- {
- int n=100, i, j, k;
- for (i=2; i<=n; i++) c[i]=i;
- i=2;
- int f=n/2;
- while (i<=f)
- {
- if (c[i])
- {
- j = 2 * i;
- while (j <= n)
- {
- c[j] = 0;
- j += i;
- }
- }
- i++;
- } //while vege
- for (int ii = 1; ii <= n; ii++)
- if (c[ii]) cout<<ii<<' ';
- cout<<endl;
- int u,s;
- int d[1000],l=1,a=1;
- d[1000]={};
- for(int j=1;j<=n;j++)
- {
- if(c[j])
- {
- d[l]=j;//ide menti a primeket
- l++;
- if(l>3)
- {
- A[a]=d[a]+d[a+1]+d[a+2];
- cout<<d[a]<<' ';
- a++;
- }
- }
- }
- while(A[u]<=n)
- u++;
- u--;
- cout<<endl;
- cout<<n<<": "<<A[u]<<endl;
- cout<<d[u]<<' '<<d[u+1]<<' '<<d[u+2]<<' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement