HDU2052Picture

本文章仅用于笔记。部分知识点来源于网络,授权请联系作者([email protected])。



题目


Give you the width and height of the rectangle,darw it.
InputInput contains a number of test cases.For each case ,there are two numbers n and m (0 < n,m < 75)indicate the width and height of the rectangle.Iuput ends of EOF. OutputFor each case,you should draw a rectangle with the width and height giving in the input. 
after each case, you should a blank line. Sample Input
3 2
Sample Output
+---+
|   |
|   |
+---+


解题


import java.util.Scanner;

public class Main
{
//Picture
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		while(s.hasNextInt())
		{
			int n=s.nextInt();
			int m=s.nextInt();
			System.out.print("+");
			for(int i=0;i<n;i++)
				System.out.print("-");
			System.out.println("+");
			for(int i=0;i<m;i++)
			{
			     System.out.print("|");
			     for(int j=0;j<n;j++)
						System.out.print(" ");
			     System.out.println("|");
			}
			System.out.print("+");
			for(int i=0;i<n;i++)
				System.out.print("-");
			System.out.println("+");
			System.out.println();
		}
	}
}


求来波关注! 谢谢啦0.0!

小小小作者 
@Fanny0602

猜你喜欢

转载自blog.csdn.net/qq_40833874/article/details/78726482
今日推荐