To spell out a nice table

Source: Internet
Author: User
Tags stub
Package Cn.dlpu.lby;

Import Java.util.Scanner;
 /* Spell out beautiful forms * in the Chinese Windows Environment, the console window can also be used to spell beautiful tables with special symbols.   For example: ┌─┬─┐│││├─┼─┤│││└─┴─┘ Actually, it is by the following symbol splicing: Left upper =┌ Upper =┬ right Upper =┐ left =├ center =┼ right =┤ lower left =└
 ┴ right down =┘ vertical =│ level =─ This topic requires a program to draw the corresponding table according to the number of rows and columns entered by the user. For example user input: 3 2 program output: ┌─┬─┐│││├─┼─┤│││├─┼─┤│││└─┴─┘ user input: 2 3 program output: ┌─┬─┬─┐││││├─┼─┼─┤││ ││└─┴─┴─┘ requires candidates to write all classes in a file. After debugging, deposit with the candidate folder corresponding to the "answer. txt" in the title can be. The relevant engineering documents should not be copied into.
 Please do not use the package statement. In addition, only the syntax or invocation allowed in JDK1.5 can appear in the source program.
 You cannot use version 1.6 or later.
		*/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 stub for (int i = 0; I <= N; i++) {
					for (int j = 0; J <= M; j + +) {if (i = = 0) {//First line if (j = = 0) System.out.print ("┌─");
						else if (J > 0 && J < m) {System.out.print ("┬─");
						} else {System.out.println ("┐");
					Add (j);
					}}//middle row 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);
				}}//Last line else{if (j = = 0) {System.out.print ("└─");
				} else if (J > 0 && J < m) {System.out.print ("┴─");
				} else System.out.print ("┘");
			}}}} private static void Add (int j) {//TODO auto-generated method stub for (int i = 0; i < J; i++) {
		System.out.print ("│");
	} System.out.println ("│");
 }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.