We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
public class ChengFaBiao{ public static void main(String[] args){ bianLian1(); bianLian2(); bianLian3(); bianLian4(); bianLian5(); bianLian6(); } public static void bianLian1(){ for(int i=1;i<=9;i++) { for(int j=1;j<=i;j++){//把嵌套看成内循环是输一行数据,外循环是输出多行内循环的数据 System.out.print(j+"*"+i+"="+i*j+"\t"); } System.out.println(); } System.out.println("----------------------"); } public static void bianLian2(){ for(int i=9;i>=1;i--){ for( int j=1;j<=i;j++){ System.out.print(j+"*"+i+"="); System.out.printf("%2d ",i*j);//%2d是至少输出占有两个字符的十进制整数 } System.out.println(""); } System.out.println("----------------------"); } public static void bianLian3(){ for(int i=9;i>=1;i--){ for (int m=1;m<=9-i;m++) System.out.print(" "); for( int j=1;j<=i;j++){ System.out.print(j+"*"+i+"="); System.out.printf("%2d ",i*j);//%2d是至少输出占有两个字符的十进制整数。 } System.out.println(""); } System.out.println("----------------------"); } public static void bianLian4(){ for(int i=9;i>=1;i--){ for( int j=1;j<=i;j++){ System.out.print(j+"*"+i+"="+i*j+"\t"); } System.out.println(); for( int j=0;j<=9-i;j++){ System.out.print("\t"); } } System.out.println(); System.out.println("----------------------"); } public static void bianLian5(){ for(int i=1;i<=9;i++){ for (int m=1;m<=9-i;m++) System.out.print(" "); for( int j=1;j<=i;j++){ System.out.print(j+"*"+i+"="); System.out.printf("%2d ",i*j);//%2d是至少输出占有两个字符的十进制整数。 } System.out.println(); } System.out.println("----------------------"); } public static void bianLian6(){ for(int i=1;i<=9;i++){ for( int j=1;j<=9-i;j++){ System.out.print("\t"); } for( int j=1;j<=i;j++){ System.out.print(j+"*"+i+"="+i*j+"\t"); } System.out.println(); } System.out.println("----------------------"); } } /** bianlian1()方法显示效果: 1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3=9 1*4=4 2*4=8 3*4=12 4*4=16 1*5=5 2*5=10 3*5=15 4*5=20 5*5=25 1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36 1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49 1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64 1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81 ---------------------- bianlian2()方法显示效果: 1*9= 9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81 1*8= 8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64 1*7= 7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49 1*6= 6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36 1*5= 5 2*5=10 3*5=15 4*5=20 5*5=25 1*4= 4 2*4= 8 3*4=12 4*4=16 1*3= 3 2*3= 6 3*3= 9 1*2= 2 2*2= 4 1*1= 1 ---------------------- bianlian3()方法显示效果: 1*9= 9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81 1*8= 8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64 1*7= 7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49 1*6= 6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36 1*5= 5 2*5=10 3*5=15 4*5=20 5*5=25 1*4= 4 2*4= 8 3*4=12 4*4=16 1*3= 3 2*3= 6 3*3= 9 1*2= 2 2*2= 4 1*1= 1 ---------------------- bianlian4()方法显示效果: 1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81 1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64 1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49 1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36 1*5=5 2*5=10 3*5=15 4*5=20 5*5=25 1*4=4 2*4=8 3*4=12 4*4=16 1*3=3 2*3=6 3*3=9 1*2=2 2*2=4 1*1=1 ---------------------- bianlian5()方法显示效果: 1*1= 1 1*2= 2 2*2= 4 1*3= 3 2*3= 6 3*3= 9 1*4= 4 2*4= 8 3*4=12 4*4=16 1*5= 5 2*5=10 3*5=15 4*5=20 5*5=25 1*6= 6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36 1*7= 7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49 1*8= 8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64 1*9= 9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81 ---------------------- bianlian6()方法显示效果: 1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3=9 1*4=4 2*4=8 3*4=12 4*4=16 1*5=5 2*5=10 3*5=15 4*5=20 5*5=25 1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36 1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49 1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64 1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81 ---------------------- */
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: