打印一个高度为N由#符号填充的楼梯
比如N=6时
打印
#
##
###
####
#####
######
我的解答:
import java.io.*;
import java.util.*;
public class Staircase {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
for(int row = 0; row < N; row ++){
for(int space = 0; space < N - row - 1; space++){
System.out.print(" ");
}
for(int sharp = 0; sharp < row + 1; sharp++){
System.out.print("#");
}
System.out.println();
}
}
}