package cn.dlpu.lby;import java.util.Scanner;/*拼出漂亮的表格 * 在中文Windows環境下,控制台視窗中也可以用特殊符號拼出漂亮的表格來。 比如: ┌─┬─┐ │ │ │ ├─┼─┤ │ │ │ └─┴─┘ 其實,它是由如下的符號拼接的: 左上 = ┌ 上 = ┬ 右上 = ┐ 左 = ├ 中心 = ┼ 右 = ┤ 左下= └ 下 = ┴ 右下 = ┘ 垂直 = │ 水平 = ─ 本題目要求編寫一個程式,根據使用者輸入的行、列數畫出相應的表格來。 例如使用者輸入: 3 2 則程式輸出: ┌─┬─┐ │ │ │ ├─┼─┤ │ │ │ ├─┼─┤ │ │ │ └─┴─┘ 使用者輸入: 2 3 則程式輸出: ┌─┬─┬─┐ │ │ │ │ ├─┼─┼─┤ │ │ │ │ └─┴─┴─┘ 要求考生把所有類寫在一個檔案中。調試好後,存入與考生檔案夾下對應題號的“解答.txt”中即可。相關的工程檔案不要拷入。請不要使用package語句。 另外,來源程式中只能出現JDK1.5中允許的文法或調用。不能使用1.6或更高版本。 */public class Pingezi {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int m = sc.nextInt();display(n, m);}private static void display(int n, int m) {// TODO Auto-generated method stubfor (int i = 0; i <= n; i++) {for (int j = 0; j <= m; j++) {if (i == 0) { // 第一行if (j == 0)System.out.print("┌─");else if (j > 0 && j < m) {System.out.print("┬─");} else {System.out.println("┐");add(j);}}// 中間行else if (i > 0 && i < n) {if (j == 0) {System.out.print("├─");} else if (j > 0 && j < m) {System.out.print("┼─");} else{System.out.println("┤");add(j);}}// 最後一行else{ if (j == 0) {System.out.print("└─");}else if (j > 0 && j < m){System.out.print("┴─");} elseSystem.out.print("┘");}}}}private static void add(int j) {// TODO Auto-generated method stubfor (int i = 0; i < j; i++) {System.out.print("│ ");}System.out.println("│");}}