Posted by Bo0mer Sat 20th Jan 2007 10:06 - Syntax is C++ - 22 views
Download | New Post | Modify | Hide line numbers
  1. #include
  2. #include
  3. #include
  4. using namespace std;
  5. int main()
  6. {    ofstream outfile("test.txt");
  7.     int n;
  8.     int i;
  9.     int j;
  10.     int f;
  11.     cout << "n= ";
  12.     cin >> n;
  13.     for (int i = 3; ; i += 2)
  14.     {
  15.         f = 0;
  16.         for (int j = 3; j <= (int)(i / 3); j += 2)
  17.         {
  18.             if (i % j == 0)
  19.             {
  20.                 f = 1;
  21.                 break;
  22.             }
  23.         }
  24.         if (f == 0)
  25.         {
  26.             outfile << i << " ";
  27.             n = n - 1;
  28.             if (n == 0)
  29.                 break;
  30.         }
  31.     }
  32.     outfile.close();
  33. return 0;
  34. }

PermaLink to this entry https://pastebin.co.uk/9360
Posted by Bo0mer Sat 20th Jan 2007 10:06 - Syntax is C++ - 22 views
Download | New Post | Modify | Hide line numbers