background image

 

代码如下:

 #include "stdafx.h"
int Q(int z);

int Q(int z){

int rtn = 0;

for(int i = 1 ;i <= z ;i++){
for(int j = 1 ;j <= z ;j++){
if((i != 1) && (j != 1)){
if(i * j == z ){
rtn = 1;
}
}
}
}
return rtn;
}

int _tmain(int argc, _TCHAR* argv[])
{
int n;

for(int i = 2 ;i <= 100 ;i++){
n = Q(i);

if (n == 1){
continue;
}
else if (n == 0){
printf("%d\n",i);
}
}
return 0;
}