1013

作者: 峡迩 | 来源:发表于2017-07-17 23:24 被阅读0次
    #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;
    }
    

    相关文章

      网友评论

          本文标题:1013

          本文链接:https://www.haomeiwen.com/subject/ilfckxtx.html