0
Follow
0
View

99 The second row of the multiplication table cannot be aligned

lidongmei_ 注册会员
2023-02-27 17:20

Write out what style you want to implement in an excel spreadsheet and count the number of rows and columns.
There should be 10 columns. The row number takes up one column. Don't you consider that the row number takes up one column?

dl04061227 注册会员
2023-02-27 17:20

two layers of loop, the outer control row, the inner control column, and then the column is not aligned, that is the problem of the inner loop, the inner loop is 9 times, so 9 columns is no problem, you can add a judgment before the inner loop, When it's row 1, column 1 print a tab key

if(i==1&&j==1){
                 System.out.print("\t"); 
             }

img

echogreat 注册会员
2023-02-27 17:20
System . out .println(""); for ( int i= 1 ;i< 10 ;i++) { System . out .print(i+"\t"); for ( int j= 1 ;j< 10 ;j++){ System . out .print(i+"X"+j+"="+i*j+"\t"); } System . out .println(""); } } .
< !- - - - - >

About the Author

Question Info

Publish Time
2023-02-27 17:20
Update Time
2023-02-27 17:20