swich年龄 九九乘法表 空心菱形
import java.util.Scanner;
public class Demo1 {
public static void main(String[] args) {
d3();
}
/**
* swich年龄
*/
public static void d1() {
Scanner scanner = new Scanner(System.in);
int yue = scanner.nextInt();
if (yue >= 4 && yue <= 10) {
int nianling = scanner.nextInt();
if (nianling >= 60) {
System.out.println(20);
} else if (nianling >= 18) {
System.out.println(60);
} else {
System.out.println(30);
}
} else {
int nianling = scanner.nextInt();
if (nianling >= 18 && nianling <= 60) {
System.out.println(40);
} else {
System.out.println(20);
}
}
}
/**
* 九九乘法表
*/
public static void d2() {
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j + "+" + i + "=" + j * i + "\t");
}
System.out.println();
}
}
/**
* 空心菱形
*/
public static void d3() {
int tol = 14;
for (int i = 0; i < tol * 2 - 1; i++) {
if (i < tol) {
for (int k = 0; k < tol - i - 1; k++) {
System.out.print(" ");
}
for (int j = 0; j < (i + 1) * 2 - 1; j++) {
if (j == 0 || j == (i + 1) * 2 - 1 - 1) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
} else {
for (int k = 0; k < i - tol + 1; k++) {
System.out.print(" ");
}
for (int j = (tol * 2 - 1 - i) * 2 - 1; j > 0; j--) {
if (j == (tol * 2 - 1 - i) * 2 - 1 || j == 1) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
}
System.out.println();
}
}
}