2025-03-06 22:45:14 +08:00

33 lines
625 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
求100到200间的所有素数输出时每个数占5个字符宽度10个一行。要求在奇数中找素数。
结果:
101 103 107 109 113 127 131 137 139 149
151 157 163 167 173 179 181 191 193 197
199
-------------------------------------------------------*/
#include <stdio.h>
#include <math.h>
main()
{
int i,j,k,m;
k=0;
for(i=101;i<200;i+=2 )
{
m=sqrt(i);
/**********Program**********/
for(j=2;j<=m;j++){
if(i%j==0){
break;
}
}
if(j > m){
printf("%5d", i);
k++;
if(k%10==0){
printf("\n");
}
}
/********** End **********/
}
}