}
for (int h = 0;h < 1 + i * 2 ;h++ ) {
System.out.print("*");
}
System.out.println();
}作者: 哇咔咔学IT 时间: 2016-4-26 13:18
import java.util.Scanner;
class XingXing {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个正整数,强力建议3~20");
int z = sc.nextInt();
if (z > 0) {
for (int h = 1;h <= z ;h++ ) {
xing(h,z);
}
}else
System.out.println("你逗老子");
}
public static void xing(int h,int z) {
int b = h;
while ( b > 1 ) {
System.out.print(" ");
b--;
}
for (int a = z + 1 - h;a > 0 ;a-- ) {
System.out.print("*" + " ");
}
System.out.println();
}
}
倒三角作者: 1191065242 时间: 2016-4-27 22:25
Scanner sca = new Scanner(System.in); System.out.println("请输入几边三角形"); int num = sca.nextInt(); for (int i = 0; i < num; i++) { for (int j =0 ; j < num - i; j++) { System.out.print(" "); } for (int k = 0; k < i + 1; k++) { System.out.print("* "); } System.out.println(); }