cs61b: Java数据结构
Tutorial: https://sp21.datastructur.es/materials/hw/hw0/hw0
Tool:https://cscircles.cemc.uwaterloo.ca//java_visualize/#
Creative Exercise 1a: Drawing a Triangle
public class Traingle5 {
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('*');
}
System.out.println();
}
}
}
结果:
Creative Exercise 1b: DrawTriangle
Name this new method drawTriangle and give it a return type of void (this means that it doesn’t return anything at all). The drawTriangle method should take one parameter named N, and it should print out a tr