乘法口訣右對齊和左對齊
阿新 • • 發佈:2019-01-25
右對齊
package fordmeo;
public class Fordmeo {
public static void main(String[]args){
for(int i=1;i<=9;i++)
{
for(int j=1;j<=9;j++)
{
if(i*j<10)
System.out.print(" ");
System.out.printf("%d*%d=%d ", j, i, j * i);
}
System.out.println("\n");
}
}
}
左對齊
package fordmeo;
public class Fordmeo {
public static void main(String[]args){
for(int i=1;i<=9;i++)
{
for(int j=1;j<=9;j++)
{
System.out.printf("%d*%d=%d ", j, i, j * i);
if(i*j<10)
System.out.print(" ");
}
System.out.println("\n");
}
}
}