Tag: Make it terminate with a labeled break statement
Public class c3_18{ public static void main (String[] args) { Int n=0,m,j,i; p1:for (i=3;i<=100;i+=2)//outer loop, front with label { m= (int) math.sqrt ((double) i); for (j=2;j<=m;j++)//inline loop { if ((i%j) ==0) break; if (i==51) break p1;//the end of the loop }//inline loop that the label P1 points to when the condition is established if (j>=m+1) { if (n%6==0) system.out.print ("\ n");//Line break control system.out.print (i+ " "); n++; } }//outer loop ends }}
Run results
650) this.width=650; "src=" http://img.blog.csdn.net/20150723163145420 "alt=" here write a picture describing "title=" "/>
This article is from the "Sanghaidan blog column" blog, please be sure to keep this source http://10602803.blog.51cto.com/10592803/1683069
To find the prime number between 1~50 (terminating it with a labeled break statement)