package com.webkfa.test;
public class Test {
public static void main(String[] args){
printTriangle(10,4);
}
/**
* 等腰梯形
* @param len
* @param pos
*/
public static void printTriangle(int len,int pos) {
//原代码地址:http://www.webkfa.com/one7/w499.html
int a = 0;
int b = 0;
for (int i=1; i<=len; i++) {
if(i<pos)continue;
if (a != (len - i)) {
System.out.print(" ");
a++;
i = i - 1;
} else if (b != (2 * i - 1)) {
System.out.print("*");
b++;
i = i - 1;
} else if (a == (len - i) && b == (2 * i - 1)) {
System.out.println();
a = 0;
b = 0;
}
}
}
}