- /*
- 需求:在控制台输如下的形状
- *
- **
- ***
- ****
- *****
- */
- class FunctionDemo {
- public static void main(String[] args) {
- for (int x =0;x <5;x++) {
- for (int y=0;y<=x;y++) {
- System.out.print("*");
- }
- System.out.println();
- }
- //由以上三角形打印九九乘法表
- for (int x =1;x <= 9;x++) {
- for (int y =1;y<=x;y++) {
- System.out.print(y+"*"+x+"="+y*x+"\t");
- }
- System.out.println();
- }
- }
- }
复制代码
|
|