我想知道如何计算该程序的TIME复杂度,外循环中的10定义了要打印的素数。您可以假设它为N。现在,它将打印10个质数。
#include <iostream>
using namespace std;
int main()
{ int number=2;
bool flg=0;
cout<<2<<"\t";
number=3;
for(int count=1;count<10;number+=2){
for(int j = 3;j<(number/2);j+=2){
if(number%j==0){
flg=1;
break;
}
}
if(flg==0)
{cout<<number<<"\t";count++;}
else
flg=0;
}
return 0;
}