.
}
for(int k=1; k<(i+1)*2; k++) { System.out.print('*'); }
System.out.println(); }
for(int i=1; i<=H/2; i++) { for(int j=1; j<=i; j++) { System.out.print(\ }
for(int k=1; k<=W-2*i; k++) { System.out.print('*'); }
System.out.println(); } } }
¡¾³ÌÐò20¡¿
ÌâÄ¿£ºÓÐÒ»·ÖÊýÐòÁУº2/1£¬3/2£¬5/3£¬8/5£¬13/8£¬21/13...Çó³öÕâ¸öÊýÁеÄǰ20ÏîÖ®ºÍ¡£ public class lianxi20 {
public static void main(String[] args) { int x = 2, y = 1, t;
¿É±à¼
.
double sum = 0; for(int i=1; i<=20; i++) { sum = sum + (double)x / y; t = y; y = x; x = y + t; }
System.out.println(\ǰ20ÏîÏà¼ÓÖ®ºÍÊÇ£º \} }
¡¾³ÌÐò21¡¿
ÌâÄ¿£ºÇó1+2!+3!+...+20!µÄºÍ public class lianxi21 {
public static void main(String[] args) { long sum = 0; long fac = 1;
for(int i=1; i<=20; i++) { fac = fac * i; sum += fac; }
System.out.println(sum); }
¿É±à¼
.
}
¡¾³ÌÐò22¡¿
ÌâÄ¿£ºÀûÓõݹ鷽·¨Çó5!¡£ public class lianxi22 {
public static void main(String[] args) { int n = 5; rec fr = new rec();
System.out.println(n+\} } class rec{
public long rec(int n) { long value = 0 ; if(n ==1 ) { value = 1; } else {
value = n * rec(n-1); }
return value; } }
¡¾³ÌÐò23¡¿
¿É±à¼
.
ÌâÄ¿£ºÓÐ5¸öÈË×øÔÚÒ»Æð£¬ÎʵÚÎå¸öÈ˶àÉÙËꣿËû˵±ÈµÚ4¸öÈË´ó2Ëê¡£ÎʵÚ4¸öÈËËêÊý£¬Ëû˵±ÈµÚ3¸öÈË´ó2Ëê¡£ÎʵÚÈý¸öÈË£¬ÓÖ˵±ÈµÚ2ÈË´óÁ½Ëê¡£ÎʵÚ2¸öÈË£¬Ëµ±ÈµÚÒ»¸öÈË´óÁ½Ëê¡£×îºóÎʵÚÒ»¸öÈË£¬Ëû˵ÊÇ10Ëê¡£ÇëÎʵÚÎå¸öÈ˶à´ó£¿ public class lianxi23 {
public static void main(String[] args) { int age = 10;
for(int i=2; i<=5; i++) { age =age+2; }
System.out.println(age); } }
¡¾³ÌÐò24¡¿
ÌâÄ¿£º¸øÒ»¸ö²»¶àÓÚ5λµÄÕýÕûÊý£¬ÒªÇó£ºÒ»¡¢ÇóËüÊǼ¸Î»Êý£¬¶þ¡¢ÄæÐò´òÓ¡³ö¸÷λÊý×Ö¡£ //ʹÓÃÁ˳¤ÕûÐÍ×î¶àÊäÈë18λ import java.util.*; public class lianxi24 {
public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.print(\ÇëÊäÈëÒ»¸öÕýÕûÊý£º\ long a = s.nextLong(); String ss = Long.toString(a);
¿É±à¼