一、质数表

共1061个

质数表 [1000 - 10000]

质数表 [1000 - 10000]
质数表 [1000 - 10000]
质数表 [1000 - 10000]

二、代码生成

#include <iostream>

using namespace std;

int main ( void )
{
    FILE *op;
    op = fopen ( "ans.txt", "w" );
    int cnt = 0;

    for ( int i = 1001; i <= 9999; i++ )
    {
        int flag = 0;
        for ( int j = 2; j * j <= i; j++ )
        {
            if ( i % j == 0 )
            {
                flag = 1;
                break;
            }
        }

        if ( !flag )
            fprintf ( op, "%-10d", i );
        else
            fprintf ( op, "    %10s", " " );
        cnt++;

        if ( cnt % 10 == 0 ) fprintf ( op, "\n" );
    }

    fclose ( op );

    return 0;
}

相关文章:

  • 2021-12-31
  • 2021-11-17
  • 2021-11-17
  • 2021-04-08
  • 2021-11-07
  • 2022-12-23
  • 2021-11-17
猜你喜欢
  • 2022-12-23
  • 2021-11-17
  • 2021-11-17
  • 2021-11-17
  • 2021-08-04
  • 2021-11-17
  • 2021-11-17
相关资源
相似解决方案