Jobdu-14-输出梯形

Question

题目描述:

输入一个高度h,输出一个高为h,上底边为h的梯形。

输入:
一个整数h(1<=h<=1000)。

输出:
h所对应的梯形。

样例输入:
4

样例输出:

1
2
3
4
****
******
********
**********

Answer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int h = sc.nextInt();
for(int i = 0; i < h; i++){
for(int j = 0; j < 3 * h -2; j++){
if(j < 2*h-2-2*i)
System.out.print(" ");
else
System.out.print("*");
}
System.out.print("\n");
}
}
}