package org.westos.e_forfor;
/**
* 需求:99乘法表
*
* 1*1 =1
* 1*2 = 2 2*2 = 4
* 1*3 = 3 2*3 = 6
* 1*4 = 4 2*4 = 8 ......
* ...
*
*先可以完成这个需求:
* *
* **
* ***
* ****
* *****
* ******
* *******
* ********
* @author Administrator
*
* 正则表达表达式
* 转义字符:
* x字符,x代表任意字符
*
* '\t' 制表符
* 'r' 回车符
* '\n' 换行
*
*/
public class ForForDemo3 {
public static void main(String[] args) {
//for循环嵌套,完成*形状
for(int x = 0 ; x <9 ; x ++) {//行数
for(int y = 0 ; y <=x ; y++) {//列
System.out.print("*");
}
System.out.println();
}
System.out.println("------------------------------");
//为了保证使用数据,从1开始
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();
}
}
}
/**
* 需求:99乘法表
*
* 1*1 =1
* 1*2 = 2 2*2 = 4
* 1*3 = 3 2*3 = 6
* 1*4 = 4 2*4 = 8 ......
* ...
*
*先可以完成这个需求:
* *
* **
* ***
* ****
* *****
* ******
* *******
* ********
* @author Administrator
*
* 正则表达表达式
* 转义字符:
* x字符,x代表任意字符
*
* '\t' 制表符
* 'r' 回车符
* '\n' 换行
*
*/
public class ForForDemo3 {
public static void main(String[] args) {
//for循环嵌套,完成*形状
for(int x = 0 ; x <9 ; x ++) {//行数
for(int y = 0 ; y <=x ; y++) {//列
System.out.print("*");
}
System.out.println();
}
System.out.println("------------------------------");
//为了保证使用数据,从1开始
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();
}
}
}