至黑马程序员-------当程序员不容易,我会坚持!- class ForForDemo
- {
- //倒三角
- public static void main(String[] args)
- {
- for (int x=0;x<5 ;x++ )
- {
- for (int y=x;y<5 ;y++ )
- {
- System.out.print("*");
- }
- System.out.println();
- }
- /*
- 第一个:正三角
- *
- **
- ***
- ****
- *****
- 第二个:数值宝塔
- 1
- 12
- 123
- 1234
- 12345
- 第三个:九九乘法
- 1×1
- 1×1 1×2
- */
- for (int x=1;x<=5;x++ )
- {
- for (int y=1;y<=x ;y++ )
- {
- System.out.print(y);
- }
- System.out.println();
- }
- //九九乘法表
- for (int x=1;x<=9 ;x++ )
- {
- for (int y=1;y<=x ;y++ )
- {
- System.out.print(x+"×"+y+"="+x*y+"\t");
- }
- System.out.println();
- }
- }
- }
复制代码
|
|