public static void main(String[] args) { heng(); shu(); }}
不对呀 , public class mul { public static void main(String[] args) { int a, b; for (a=1;a<=9;a++) { for (b=1;b<=a;b++) { int c = a*b; System.out.print(b+"*"+a+"="+c+" "); } System.out.println(); } } } 这是上三角的,我要下三角的!!!
package com.csdn.interview;public class ChengFaBiao {
public static void heng(){
for(int i=1; i<=9; i++){
for(int j=1; j<=i; j++){
System.out.print(i+"x"+j+" ");
}
System.out.println("\n");
}
}
public static void shu(){
for(int i=1; i<=9; i++){
for(int j=1; j<=10-i; j++){
System.out.print(i+"x"+j+" ");
}
System.out.println("\n");
}
}
public static void main(String[] args) {
heng();
shu();
}}
public class mul
{
public static void main(String[] args)
{
int a, b;
for (a=1;a<=9;a++)
{
for (b=1;b<=a;b++)
{
int c = a*b;
System.out.print(b+"*"+a+"="+c+" ");
}
System.out.println();
}
}
}
这是上三角的,我要下三角的!!!
for(int j=1; j <=10-i; j++){
System.out.print(j+"*"+i+"="+j*i+" ");
}
System.out.println();
}
这段代码添到main方法的后面!
for (int i = 9; i > 0; i--) {
for (int j = 1; j <= i; j++) {
System.out.print(j + " * " + i + " = " + i * j);
System.out.print(" ");
}
System.out.println();
}
}
int i,j; for( i=1; i <=9; i++)
{
for( j=1; j <=i; j++)
{
System.out.print(j+"*"+i+"="+j*i+" ");
}
System.out.println();
}