SHARE
TWEET

program

a guest Nov 12th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int c[10000000],A[1000];
  5. void csere(int &a, int &b)
  6. {
  7.     int s=a;
  8.     a=b;
  9.     b=s;
  10. }
  11. int main()
  12. {
  13.     int n=100, i, j, k;
  14.     for (i=2; i<=n; i++) c[i]=i;
  15.         i=2;
  16.     int f=n/2;
  17.     while (i<=f)
  18.     {
  19.         if (c[i])
  20.         {
  21.  
  22.             j = 2 * i;
  23.             while (j <= n)
  24.             {
  25.                 c[j] = 0;
  26.                 j += i;
  27.             }
  28.         }
  29.         i++;
  30.     } //while vege
  31.     for (int ii = 1; ii <= n; ii++)
  32.         if (c[ii]) cout<<ii<<' ';
  33.     cout<<endl;
  34.     int u,s;
  35.     int d[1000],l=1,a=1;
  36.     d[1000]={};
  37.     for(int j=1;j<=n;j++)
  38.     {
  39.         if(c[j])
  40.         {
  41.             d[l]=j;//ide menti a primeket
  42.             l++;
  43.             if(l>3)
  44.             {
  45.                 A[a]=d[a]+d[a+1]+d[a+2];
  46.                 cout<<d[a]<<' ';
  47.                 a++;
  48.  
  49.  
  50.             }
  51.         }
  52.     }
  53.     while(A[u]<=n)
  54.         u++;
  55.     u--;
  56.     cout<<endl;
  57.     cout<<n<<": "<<A[u]<<endl;
  58.     cout<<d[u]<<' '<<d[u+1]<<' '<<d[u+2]<<' ';
  59.     return 0;
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top