首页 > ACM题库 > HDU-杭电 > hdu 2052 Picture-模拟-[解题报告]C++
2013
12-26

hdu 2052 Picture-模拟-[解题报告]C++

Picture

问题描述 :

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.

输出:

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.

样例输入:

3 2

样例输出:

+---+
|   |
|   |
+---+

题解:

  简单模拟题,不解释。

代码如下:

#include <stdio.h>

void print1(int n)
{
	int i;
	printf("+");
	for (i=0; i<n; i++)
		printf("-");
	printf("+\n");
}

void print2(int n)
{
	int i;
	printf("|");
	for (i=0; i<n; i++)
		printf(" ");
	printf("|\n");
}
int main()
{
	int m, n, i;
	while (scanf("%d%d", &n, &m) != EOF)
	{
		print1(n);
		for (i=0; i<m; i++)
			print2(n);
		print1(n);
		printf("\n");
	}
	return 0;
}

 

解题转自:http://blog.csdn.net/suifengdream/article/details/8524098


  1. 换句话说,A[k/2-1]不可能大于两数组合并之后的第k小值,所以我们可以将其抛弃。
    应该是,不可能小于合并后的第K小值吧