- public class Shuzijinzita {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- for (int i = 1; i <=9; i++) {
- for (int j = 0; j <9-i; j++) {
- System.out.print(" ");
- }
- boolean k=true;
- int l=0;
- for (int j = 1; k?(j<=i):(j>=1); l= k?(j++):(j--)) {
- System.out.print(j);
- if(j==i) k=false;
- }
- System.out.println("");
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/300520133663.html
来源: http://www.codesnippet.cn/detail/300520133663.html