问题:

開始直接用输入的数作为宽和高,但实际上要多出两行边框,所以要加一个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();
}
}
}

hdu 2052 Picture(java)的更多相关文章

  1. hdu 1002大数(Java)

    A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  2. hdu 2051 Bitset (java)

    问题: 之前做过类似题,但这次仍然不能解决相关问题. 字符串倒过来输:StringBuffer str=new StringBuffer(s); s=str.reverse().toString() ...

  3. HDU 5934 Bomb(炸弹)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  4. HDU 5734 Acperience(返虚入浑)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  5. HDU 5724 Chess(国际象棋)

    HDU 5724 Chess(国际象棋) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  6. HDU 5826 physics(物理)

     physics(物理) Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)   D ...

  7. HDU 5835 Danganronpa(弹丸论破)

     Danganronpa(弹丸论破) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  8. HDU 3085 Nightmare Ⅱ(噩梦 Ⅱ)

    HDU 3085 Nightmare Ⅱ(噩梦 Ⅱ) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Ja ...

  9. HDU 5976 Detachment(拆分)

    HDU 5976 Detachment(拆分) 00 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)   Problem D ...

随机推荐

  1. 基于opencv的人脸检测的web应用

    参考资料 https://github.com/bsdnoobz/web-based-face-detect http://opencv-code.com/projects/web-based-int ...

  2. N的互质数----欧拉函数

    Description 新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N号,凡是和会长是老朋友的,那么该会员的号码肯定和N有大于1的公约数,否则都 ...

  3. python用法笔记(数组(list、touple、dict)、字符串)

    1.产生n个全为1的数组a=[1]*n2.字符数字转化int('12')float('12.5')str(123.45)ASCII码转为相应的字符:chr(97)字符转化为相应的ASCII码:ord( ...

  4. 【Hadoop代码笔记】Hadoop作业提交之Job初始化

    一.概要描述 在上一篇博文中主要描述了JobTracker和其几个服务(或功能)模块的接收到提交的job后的一些处理.其中很重要的一部分就作业的初始化.因为代码片段图的表达问题,本应该在上篇描述的内容 ...

  5. *nix高手站点

    http://linux.die.net/man/7/ip http://www.neuma.com/  cm+企业开发生命周期管理 http://book.2cto.com/201307/27394 ...

  6. 【多线程同步案例】Race Condition引起的性能问题

    Race Condition(也叫做资源竞争),是多线程编程中比较头疼的问题.特别是Java多线程模型当中,经常会因为多个线程同时访问相同的共享数据,而造成数据的不一致性.为了解决这个问题,通常来说需 ...

  7. http://acm.hdu.edu.cn/showproblem.php?pid=2579

    #include<stdio.h> #include<string.h> #include<queue> #define N 110 int m, n, k, x1 ...

  8. git会议分享

    git add . git add -A git add common.scss   只迁入某个文件 git pull h5 远程的:分支    这样就成功拉取一个新分支了 git push h5(远 ...

  9. 深入理解CRITICAL_SECTION

    临界区是一种防止多个线程同时执行一个特定代码节的机制,这一主题并没有引起太多关注,因而人们未能对其深刻理解.在需要跟踪代码中的多线程处理的性能时,对 Windows 中临界区的深刻理解非常有用.本文深 ...

  10. 【转】Android 实现蘑菇街购物车动画效果

    原文出处:http://blog.csdn.net/wangjinyu501/article/details/38400479 1.思路   目前想到两种方式实现这种效果,一是使用Tween动画,直截 ...