1013 数素数 (20分)

#include <iostream>
#include <string.h>
#include <cmath>
using namespace std;

int main()
{
    int m,n,count=0,w=0,c = 0;
    cin>>m>>n;
    for(int i=2;i<500000;i++)
    {
        w=0;
        for(int j=2;j<=sqrt(i);j++)
        {
            if(i%j==0)
            {
                w=1;
                break;
            }
        }
        if(w==0)
        {
            count++;
            if(count>=m&&count<=n)
            {
                cout<<i;
                c++;
                if(c%10==0)
                    cout<<endl;
                else if(c%10!=0&&count<n)
                    cout<<" ";
            }
        }
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/QRain/p/12221329.html
今日推荐