hdu 2052 Picture(java)

问题:

開始直接用输入的数作为宽和高,但实际上要多出两行边框,所以要加一个2。

还有题目要求最后要输出一个空行没有注意到。

Picture

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 19789    Accepted Submission(s): 10178

Problem Description

Give you the width and height of the rectangle,darw it.

Input

Input 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.

Output

For 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.*;

public class Main{
	public static void n1(int t){
		String s="";
		for(int i=1;i<=t;i++){
			if(i==1||i==t)
				s=s+"+";
			else
				s=s+"-";
		}
		System.out.println(s);
	}
	public static void n2(int t){
		String s="";
		for(int i=1;i<=t;i++){
			if(i==1||i==t)
				s=s+"|";
			else
				s=s+" ";
		}
		System.out.println(s);
	}
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		while(cin.hasNext()){
			int n=cin.nextInt();
			int m=cin.nextInt();
			int t=n+2;
			for(int i=0;i<m+2;i++){
				if(i==0||i==m+1)
					n1(t);
				else
					n2(t);
			}
			System.out.println();
		}
	}
}
时间: 2024-11-07 16:13:48

hdu 2052 Picture(java)的相关文章

hdu 1002大数(Java)

A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 230395    Accepted Submission(s): 44208 Problem Description I have a very simple problem for you. Given two integers A and B, you

hdu 2051 Bitset (java)

问题: 之前做过类似题,但这次仍然不能解决相关问题. 字符串倒过来输:StringBuffer str=new StringBuffer(s); s=str.reverse().toString() Bitset Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 15548    Accepted Submission(s): 11804

hdu 2039 三角形 (java)

问题: 一个这么简单的问题交了几遍,我也是醉了,题目并没有说边都是整数,故不能有int型 三角形 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 57701    Accepted Submission(s): 19526 Problem Description 给定三条边,请你判断一下能不能组成一个三角形. Input 输入数据第一行

hdu 2040 亲和数 (java)

问题: 开始给for循环的J设置了小于根号a,导致约数没有全部得到. 亲和数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 26302    Accepted Submission(s): 15814 Problem Description 古希腊数学家毕达哥拉斯在自然数研究中发现,220的所有真约数(即不是自身的约数)之和为: 1+

hdu Eddy&#39;s picture (最小生成树)

Eddy's picture Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 29   Accepted Submission(s) : 26 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Eddy begins to like pa

hdu 1162 Eddy&#39;s picture(最小生成树)

Problem Description Eddy begins to like painting pictures recently ,he is sure of himself to become a painter.Every day Eddy draws pictures in his small room, and he usually puts out his newest pictures to let his friends appreciate. but the result i

HDU 5047 Sawtooth (JAVA大数类)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5047 题面: Sawtooth Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1636    Accepted Submission(s): 637 Problem Description Think about a plane: ● O

[ACM] hdu 1260 Tickets (动态规划)

Tickets Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 4   Accepted Submission(s) : 2 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Jesus, what a great movie! Thou

Eddy&#39;s picture(最小生成树)

Eddy's picture Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 228 Accepted Submission(s): 168   Problem Description Eddy begins to like painting pictures recently ,he is sure of himself to become