解题输入一个字符,最后输出金字塔
字符金字塔
http://www.nowcoder.com/questionTerminal/0fae60c3b5c64699b7c0f031c2187dde
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Object object = scanner.next(); testA(object); } public static void testA(Object obj){ String a = " "; int x = 1; for (int i = 5 ; i > 0 ; i--){ for (int j = 0 ; j < i - 1; j++){ System.out.print(a); } for (int k = 1 ; k <= x*2 -1 ; k++){ if (k%2==0){ System.out.print(a); }else { System.out.print(obj); } } x++; System.out.println(); } } }