问题:

開始直接用输入的数作为宽和高,但实际上要多出两行边框,所以要加一个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. opencv3.0 在 android 上的使用

    下载 OpenCV-3.0.0-android-sdk-1.zip 打开 intellj,新建立一个 android 工程后选择工程属性,导入模块(Import module from externa ...

  2. python中的文件

    Python文件 1.    概述 文件对象不仅可以用来访问普通的磁盘文件,也可以访问任何其他类型抽象层面上的文件. 内建函数open()以及file()提供了初始化输入输出(I/O)操作的通用接口. ...

  3. Visual Studio 2010+Oracle 10g +NHibernate配置

    南京酷都面试,考官问:你知道NHibernate吗?瞬间我就急了:只听说过Hibernate,NHibernate是什么?还有其他问题也是不知道,所以后果就悲剧了. 自己做一个小系统,总是想如果数据量 ...

  4. Linux学习--第二波

    虽然安装的centos感觉不能上网,权限也不知道怎么设置. 偶然的机会发现了一个好东西,博客:http://www.cnblogs.com/xiaoluo501395377/tag/CentOS/.有 ...

  5. 最好的10本适用于初学者阅读的javaScript和jQuery书籍

    现在有许多方式学习新的内容,但是对于刚开始学习和寻找真正沉迷其中的平和状态的人而言,经典的纸质书籍依旧是首选.我发现阅读一本纸质书籍会让自己远离那些在使用电脑和平板时出现的令人不安的情绪.电子书和播客 ...

  6. Camel In Action 阅读笔记 第一章 认识Camel 1.1 Camel 介绍

    1.1 Camel 介绍 Camel 是一个为了您的项目集成变得高效有趣的集成框架,Camel 项目在2007年初开始的,相对来说它还比较年轻,但它已然是一个非常成熟的开源项目,它所使用的是Apach ...

  7. 《Java数据结构与算法》笔记-CH4-6优先级队列

    /** * 优先级队列 * 效率:插入O(n),删除O(1).第12章介绍如何通过堆来改进insert时间 */ class PriorityQueue { private int maxSize; ...

  8. 利用AuthorizeAttribute属性简单避免 MVC 中的跨域攻击

    跨域攻击---自然来路页面和目标页面不在同一个域下,所以直接判断来路域和当前自己的域就可以了. 可以广泛应用于表单提交,ajax调用或者某些不想让用户直接输入网址看到的页面 [csharp] view ...

  9. C#完整的通信代码(点对点,点对多,同步,异步,UDP,TCP)

    C# code namespace UDPServer { class Program { static void Main(string[] args) { int recv; byte[] dat ...

  10. UVa11235 FrequentValues(RMQ)

    Problem F: Frequent values You are given a sequence of n integers a1 , a2 , ... , an in non-decreasi ...