packagelesson.l2_for;//打印//*//**//***//****//*****publicclassForDemo9{publicstaticvoidmain(String[] args){for(int i =1; i <=5; i++){for(int j =1; j <= i; j++){System.out.print("*");}System.out.println();}}}
代码2-1
packagelesson.l2_for;//打印//****//***//**//*publicclassForDemo10{publicstaticvoidmain(String[] args){for(int i =4; i >=1; i--){for(int j = i; j >=1; j--){System.out.print("*");}System.out.println();}}}
代码2-2
packagelesson.l2_for;//打印//****//***//**//*publicclassForDemo10_2{publicstaticvoidmain(String[] args){for(int i =1; i <=4; i++){for(int j =1; j <=5-i ; j++){System.out.print("*");}System.out.println();}}}
代码3
packagelesson.l2_for;//打印//*//**//***//****//*****//****//***//**//*publicclassForDemo11{publicstaticvoidmain(String[] args){for(int i =1; i <=5; i++){for(int j =1; j <= i; j++){System.out.print("*");}System.out.println();}for(int i =1; i <=4; i++){for(int k =1; k <=5- i; k++){System.out.print("*");}System.out.println();}}}
代码4
packagelesson.l2_for;//打印棱形publicclassForDemo12{publicstaticvoidmain(String[] args){for(int i =1; i <=5; i++){for(int j =1; j <=6-i; j++){System.out.print(" ");}for(int k =1; k <= i; k++){System.out.print(" *");}System.out.println();}for(int i =1; i <=4; i++){for(int j =1; j <=i+1; j++){System.out.print(" ");}//for (int j = i; j <=4; j++) {for(int j =1; j <=5-i; j++){System.out.print(" *");}System.out.println();}}}
展开全部
import itertools
import time
N 2000000
L range(N)
def findnxt(s):
flag 0
for n in itertools.ifilter(None, L[s1:]):
return n
t0 time.time()
n 2
X int(N ** .5)
while n < X:
for i, x in enumerate(L[::n][1:]):
if i0: continue
L[x] 0
n findn…