1013

#include<iostream>
#include<string>
#include<vector>
#include<cmath>

using namespace std;

bool zhishu_judge(unsigned num)
{
    for (int i = 2; i <=sqrt(num); ++i)
    {
        if (num%i == 0)
            return false;
    }
    return true;
}

vector<int> zhishu(unsigned rge)
{
    vector<int> zs = { 2 };
    unsigned count = 1;
    
    for (unsigned i = 3;; ++i)
    {
        if (zhishu_judge(i))
        {
            zs.push_back(i);
            ++count;
        }
        if (count == rge)
            return zs;
    }
}

int main()
{
    unsigned m, n;
    cin >> m >> n;

    vector<int> zhishu_range = zhishu(10000);

    int col = 0;
    for (int i = m-1; i < n; ++i)
    {
        
        if (i == (n - 1))
        {
            cout << zhishu_range[i];
        }
        else
        {
            if (col % 10 < 9)
            {
                cout << zhishu_range[i] << " ";
            }
            else
            {
                cout << zhishu_range[i] << endl;
            }
        }
        ++col;
    }

    system("pause");
    return 0;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容