J2SE基础/图形打印

/**
	 * 打印图形
	 * eg:
	 * @param m
	 */
	static void printGraph(int m) {
		for (int i = 1, j = 0; i <= m;) {
			if (i <= m / 2) {
				if (j < (2 * i - 1)) {
					System.out.print("*");
					j++;
					continue;
				}
			} else if (i == (m + 1) / 2) {
				if (j < (2 * i - 1)) {
					System.out.print("*");
					j++;
					continue;
				}
			} else {
				if (j < (2 * (m - i) + 1)) {
					System.out.print("*");
					j++;
					continue;
				}
			}
			j = 0;
			i++;
			System.out.println();
		}
	}
 

你可能感兴趣的:(JavaSE,打印图形)