hdoj2052Picture
2016-05-23 20:38
381 查看
[align=left]Problem Description[/align]
Give you the width and height of the rectangle,darw it.
[align=left]Input[/align]
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.
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
[align=left]Sample Output[/align]
题意:给出矩形的场合宽,输出一个矩形,如示例所示,四个角是+。然后用for循环就可以了
代码如下:
Give you the width and height of the rectangle,darw it.
[align=left]Input[/align]
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.
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
3 2
[align=left]Sample Output[/align]
+---+ | | | | +---+
题意:给出矩形的场合宽,输出一个矩形,如示例所示,四个角是+。然后用for循环就可以了
代码如下:
#include<stdio.h> int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF) { int i,j; for(i=1;i<=m+2;i++) { for(j=1;j<=n+2;j++) { if((i==1||i==m+2)&&(j==1||j==n+2)) { printf("+"); } else if(i==1||i==m+2) { printf("-"); } else if((i!=1&&i!=m+2)&&(j==1||j==n+2)) { printf("|"); } else printf(" "); if(j==n+2) { printf("\n"); } } if(i==m+2) printf("\n"); } } }
相关文章推荐
- 【CF52C】Circular RMQ(线段树区间加减,区间最值)
- CentOS 7编译安装Nginx1.9.0
- Dos界面 五步棋
- zoj(1095)
- 关于c语言程序的感受
- DataInputString
- maven整合:最新ssm框架实现spring4.2,springmvc4.2,mybatis3.2
- zookeeper基本API的使用
- 第十一周项目1-分数类中的运算符重载(1)
- OC 习题:股票K线计算
- 添加远程库
- Codeforces Round #353 (Div. 2) E 线段树+dp
- POJ 2114 Boatherds 树的分治
- {题解}[jzoj3396] 【NOIP2013模拟】Rainbow的信号
- 【NOIP2013模拟】Rainbow的信号
- struts2运行出现The requested is not available(404)错误,解决方案
- 允许ubuntu下mysql远程连接
- 项目32-警察与厨师
- oracle 高级分组
- Python写的嗅探器——Pyside,Scapy