picture(长方形)

Picture

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

Total Submission(s): 19457    Accepted Submission(s): 10008

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。

#include<stdio.h>
//#include<stdlib.h>
main()
{
  int a,b,c,j,i,k;
  while(scanf("%d%d",&a,&b)!=EOF)
 { for(i=0;i<a+2;i++)
  {
  if(i==0||i==a+1)
  //printf(‘ ‘);
    printf("+");
 else
  printf("-");
  if(i==a+1)
  printf("\n");
                }
  for(i=0;i<b;i++)
  for(j=0;j<a+2;j++)
  {if(j==0||j==a+1)
  printf("|");
  else printf(" ");
  if(j==a+1)
  printf("\n");}
  for(i=0;i<a+2;i++)
  {
  if(i==0||i==a+1)
  //printf(‘ ‘);
    printf("+");
 else
  printf("-");
  if(i==a+1)
  printf("\n");
                }
   printf("\n");             }
 // system("pause");
      return 0;
      }

[ Copy to Clipboard ]    [ Save to File]

Sample Input

3 2

Sample Output

+---+
|   |
|   |
+---+
时间: 2024-08-14 09:31:51

picture(长方形)的相关文章

HDU 1828 Picture(长方形的周长和)

HDU 1828 Picture 题目链接 题意:给定n个矩形,输出矩形周长并 思路:利用线段树去维护,分别从4个方向扫一次,每次多一段的时候,就查询该段未被覆盖的区间长度,然后周长就加上这个长度,4个方向都加完就是答案 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N = 5005; int n; struct Rec { int

【转】像素 Pixel (Picture Element)

原文链接:https://blog.csdn.net/zssureqh/article/details/78768942 1.像素Pixel 讲到概念,首选Wiki百科.当然我说的是英文版Pixel Wiki,中文版中的大多数词条真是不敢苟同.这里请允许我先摘录英文Wiki中对Pixel定义的原文: In digital imaging, a pixel, pel, dots, or picture element is a physical point in a raster image, o

要求用户输入宽和高,显示出长方形的面积。

import java.util.Scanner; /** * @author 蓝色以太 * 要求用户输入宽和高,显示出长方形的面积. */ public class Area { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("请输入长度:"); double length=sc.nextDouble(); System.out.printl

HDU 1828 Picture(矩形周长并)

HDU 1828 Picture 题目链接 题意:给定n个矩形,输出矩形周长并 思路:利用线段树去维护,分别从4个方向扫一次,每次多一段的时候,就查询该段未被覆盖的区间长度,然后周长就加上这个长度,4个方向都加完就是答案 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N = 5005; int n; struct Rec { int

hdu 1859 最小长方形

Description 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内. Input 测试输入包含若干测试用例,每个测试用例由一系列坐标组成,每对坐标占一行,其中|x|和|y|小于 231:一对0 坐标标志着一个测试用例的结束.注意(0, 0)不作为任何一个测试用例里面的点.一个没有点的测试用例标志着整个输入的结束. Output 对每个测试用例,在1行内输出2对整数,其间用一个空格

Project Euler 85 :Counting rectangles 数长方形

Counting rectangles By counting carefully it can be seen that a rectangular grid measuring 3 by 2 contains eighteen rectangles: Although there exists no rectangular grid that contains exactly two million rectangles, find the area of the grid with the

usaco Picture

/* ID: modengd1 PROG: picture LANG: C++ */ #include <iostream> #include <stdio.h> #include <memory.h> #include <vector> #include <algorithm> using namespace std; int N; struct edge { int y,x1,x2; bool isbegin; bool friend ope

Hole puncher Show Picture

import sys reload(sys) sys.setdefaultencoding('utf8') import matplotlib.pyplot as plt import string file = open("GD.txt") i = 0 x = range(0) y = range(0) for line in file: x.append(string.atoi(line[0:7], 10)) y.append(string.atoi(line[8:], 10))

杭电1162--Eddy&#39;s picture(Prim()算法)

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