输出前20个素数的c++
急求
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a, t, leap;
cout<< "输入一个数:" <<endl;
cin>> a;
for (int k = 1; k <=a ;k++)
{
t = sqrt(k);
for (int i = 2; i <= t; i++)
{
if (k % i == 0)
{
leap = 0;
break;
}
else
leap = 1;
}
if (leap == 1)
cout<< k << "是素数" <<endl;
else if (leap == 0)
cout<< k << "不是素数" <<endl;
}
return 0;
}