用while,和for分别实现九九乘法表

package ex;

public class chengfabia {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int i,j;
        for(i=1;i<=9;i++){
            for(j=1;j<=i;j++) {
            System.out.print(i+"*"+j+"="+i*j);
            }
            System.out.println(" ");
        }
        System.out.println(" ");
        
        
        int a=1;
        while(a<=9) {
            int b=1;
            while(b<=a) {
                System.out.print(a+"*"+b+"="+a*b);
                b++;
            }
            System.out.println(" ");
            a++;
        }
        System.out.println(" ");
    }
}

猜你喜欢

转载自www.cnblogs.com/anlyf/p/10057054.html