杭电oj —— 2052
package com.demo2;import java.util.Scanner;/** Give you the width and height of the rectangle(矩形),darw it.* * 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.* * 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.* */
public class HDU_oj2052 {public static void main(String[] args) {Scanner sn = new Scanner(System.in);while (sn.hasNext()) {int width = sn.nextInt();int height = sn.nextInt();width = width + 2;height = height + 2;/** width: 3 height:2 * +---+ * | | * | | * +---+*/char[][] arr = new char[height][width];for (int i = 0; i < height; i++) {for (int j = 0; j < width; j++) {if (i == 0 || i == height - 1) {if (j == 0 || j == width - 1)arr[i][j] = '+';elsearr[i][j] = '-';} else if ((i > 0 && i < height - 1) && (j == 0 || j == width - 1)) {arr[i][j] = '|';} else {arr[i][j] = ' ';}}}for (int i = 0; i < height; i++) {for (int j = 0; j < width; j++) {System.out.print(arr[i][j]);}System.out.println();}System.out.println();}sn.close();}
}
杭电oj —— 2052相关推荐
- 【ACM】杭电OJ 2037
题目链接:杭电OJ 2037 先把b[i]进行排序,然后,b[i]与a[i+1]进行比较. #include <iostream> #include <cstdio> #inc ...
- 【ACM】杭电OJ 2020(排序)
题目链接:杭电OJ 2020 排序可以有冒泡排序,选择排序,或者直接调用函数. 下面是选择排序: #include <stdio.h> #include <math.h> in ...
- 【ACM】杭电OJ 2018
题目链接:杭电OJ 2018 从n>4开始,每一年的牛的数量=前一年的牛的数量+三年前的牛的数量 问:为什么是三年前? 答:假设三年前有一头小牛出生,出生的那一年即为第一年,到了第四年,即三年后 ...
- 【ACM】杭电OJ 1005
题目链接:杭电OJ 1005 超时代码如下(而且开辟的数组空间大小不够): #include <stdio.h> int m[100000]; int f(int n,int a,int ...
- 【ACM】杭电OJ 1004
题目链接:杭电OJ 1004 运行环境:Dev-C++ 5.11 思路: 先把先把num数组全部赋值为1:第一个颜色单独输入,从第二个开始,需要与前面的进行比较,如果前面有相同的颜色,则在目前的nu ...
- 【ACM】杭电OJ 2012。
题目链接:杭电OJ 2012 思路很简单,但是有一种高效算法显示编译错误,不知道为什么 运行环境:VS2017 AC代码: #include <stdio.h> #include < ...
- 【ACM】杭电OJ 1003。
运行环境VS2017 题目链接:杭电OJ 1003 主要思想是: 用d[i]来存放前i项中最大的和,得到end,然后再倒推,得起始的位置begin 然而在程序42行的疑问,大家可以讨论一下吗???? ...
- 【ACM】杭电OJ 1241(深度优先搜索小结)
题目链接:杭电OJ 1241 深度优先搜索问题 深度优先搜索是搜索的手段之一.它从某个状态开始,不断地转移状态直到无法转移,然后回退到前一步的状态,继续转移到其他状态,如此不断重复,直至找到最终的解. ...
- 【ACM】杭电OJ 1096
题目链接:杭电OJ 1096 只要注意输出格式就好,其他没有问题! #include <stdio.h> int main () {int a,N,n,sum;scanf("% ...
- 【ACM】杭电OJ 2007
题目链接:杭电OJ 2007 本题容易出错的地方在于:要考虑输入的两个数的大小,一定是小的在前,大的在后 #include "stdio.h" int main () {int a ...
最新文章
- OGG维护优化脚本(一)-需求分析篇
- OCR文字识别软件的快速任务功能如何用
- 数字电路可控门电路原理(三态/同相/反相、缓冲/驱动电路)
- Securing the Deep Learning Stack
- HDU 6741 MUV LUV UNLIMITED (博弈论)
- 【算法系列之万字总结常用的查找算法,持续补充更新中】
- 文献学习(part29)
- 当自己犹豫时,坐下来读一读
- php ajax简单实例代码,Ajax的简单实用实例代码
- 归并排序的C++实现
- 服务器运维应该报什么专业,数据中心基础设施运维人员应该掌握哪些专业技能?...
- java 同步块_java 同步块(Java Synchronized Blocks)
- swfobject简单封装
- 腾讯校招java面经_腾讯校招技术岗面试经历及总结(笔试-一面-二面-终面均通过)...
- 数据分析报告结构规范设计
- 2021 MoDnet-V 抠图网络论文学习笔记
- 2020_ACL_A Transformer-based joint-encoding for Emotion Recognition and Sentiment Analysis
- H5 VIDEO标签视频黑屏的原因及解决方法
- LeetCode知识点总结 - 997
- java 云笔记_云笔记系统的设计与实现 PDF 下载
热门文章
- 解决修改jsp代码之后,浏览器刷新页面却没有变化
- PMP课程笔记:第7章 项目成本管理
- python手机代码编辑器_Pycharm(Python代码编辑器) V2020.1.2 官方版
- 计算机主机配件及图解,组装电脑需要哪些配件?电脑组装教程之全程指导新手装机图解!...
- 用户体验与可用性测试
- sz命令获取文件到本地路径设置
- [设计]2019年全国电子设计竞赛A题-电动小车动态无线充电系统
- 2018年大学生设计竞赛浙江赛区C题-无线充电电动小车-试题分析
- 第十七届全国大学生智能车竞赛华南赛区报名信息
- 基于微信小程序毕业论文选题系统(微信小程序毕业设计)