1. Creative Exercise 1a: Drawing a Triangle
要求:
使用以下code绘制三角形(这些行可能会使用一次、多次或根本不使用)
col = col + 1; int col = 0; int row = 0; int SIZE = 5; row = row + 1; System.out.print('*'); System.out.println('*'); System.out.println(); while (col <= row) { while (col < row) { while (row < SIZE) { while (row <= SIZE) { }
代码:
public class DrawTriangle {
public static void main(String[] args) {
int col = 0;
int row = 0;
int size = 5;
while (row <= size){
row = row + 1;
col = 0;
while(col < row){
col = col + 1;
System.out.print('*');
}