计算素数的程序,能否不使用goto语句而得到更简练的程序?
#include<math.h>#include<stdio.h>main(){ int i,j; for (i=2;i<100;i++) { for (j=2;j<=sqrt(i);j++) { if (i%j==0) goto loop; } printf("%d ",i); loop:; }}
#include<math.h>#include<stdio.h>int main(){ int i,j; for (i=2;i<100;i++) { for (j=2;j<=sqrt(i);j++) { if (i%j==0) { break; } } if(j>sqrt(i))printf("%d ",i); } return 0;}