代码语言:javascript复制
package *;
/**
* @program: data-structure
* @description: 直角三角形
* @author: ChenWenLong
* @create: 2019-09-10 15:07
**/
public class RightTriangle {
public static void main(String[] args) {
createRightTriangle(8);
}
/**
* 功能描述:
* 〈打印指定行数line的直角三角形〉
*
* @params : [line]
* @return : void
* @author : cwl
* @date : 2019/9/10 15:10
*/
public static void createRightTriangle(int line){
if(line < 1 ){
throw new RuntimeException("line must be greater than one");
}
//外层循环控制行数
for(int j = 0;j < line;j ){
//每行输出j 1个
for(int i = 0;i < j 1;i ){
System.out.print("*");
}
System.out.println();
}
}
}