二胖爱编程
2017-07-14 10:11:08浏览 4519
package com.zmj.nineNine;
import java.util.InputMismatchException;
import java.util.Scanner;
import javax.swing.RowFilter;
/**
* 功能:输出一个9*9的乘法表
* @author Administrator
*
*/
public class NineXNine {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int row = 0;
System.out.println("请输入乘法表的行数:");
try {
row = input.nextInt();
} catch (InputMismatchException e) {
System.out.println("请输入整数类型的行数值(1-9):");
String string = input.nextLine();
row = input.nextInt();
}finally {
System.out.println("打印9*9的乘法表");
for (int i = 1; i <= row;i++) {
for (int j = 1; j<=i; j++) {
System.out.print(i+"*"+j+"="+i*j+"\t");//不能换行
}
System.out.println();//执行完一次外循环,换行
}
}
}
}