杭电2052简单代码
2015-12-26 18:39
483 查看
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
+---+
| |
| |
+---+
#include<stdio.h>
main()
{
int x,y;
while(scanf("%d %d",&x,&y)!=EOF)
{
int i,j;
printf("+");
for(i=1;i<=x;i++)
printf("-");
printf("+");
for(j=1;j<=y;j++)
{
printf("\n");
printf("|");
for(i=1;i<=x;i++)
printf(" ");
printf("|");
}
printf("\n");
printf("+");
for(i=1;i<=x;i++)
printf("-");
printf("+");
printf("\n");
printf("\n");
}
return 0;
}
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
+---+
| |
| |
+---+
#include<stdio.h>
main()
{
int x,y;
while(scanf("%d %d",&x,&y)!=EOF)
{
int i,j;
printf("+");
for(i=1;i<=x;i++)
printf("-");
printf("+");
for(j=1;j<=y;j++)
{
printf("\n");
printf("|");
for(i=1;i<=x;i++)
printf(" ");
printf("|");
}
printf("\n");
printf("+");
for(i=1;i<=x;i++)
printf("-");
printf("+");
printf("\n");
printf("\n");
}
return 0;
}
相关文章推荐
- 简单的四则运算
- 数的奇偶性
- ACM网址
- 1272 小希的迷宫
- 1272 小希的迷宫
- hdu 1250 大数相加并用数组储存
- 矩阵的乘法操作
- 蚂蚁爬行问题
- 蚂蚁爬行问题
- 求两个数的最大公约数【ACM基础题】
- 打印出二进制中所有1的位置
- 杭电题目---一只小蜜蜂
- HDOJ 1002 A + B Problem II (Big Numbers Addition)
- 初学ACM - 半数集(Half Set)问题 NOJ 1010 / FOJ 1207
- 初学ACM - 组合数学基础题目PKU 1833
- POJ ACM 1002
- POJ 2635 The Embarrassed Cryptographe
- POJ 3292 Semi-prime H-numbers
- POJ 2773 HAPPY 2006
- POJ 3090 Visible Lattice Points