2033 - P342 12

P342 12

题目输入

n

题目输出

stars

输入/输出样例

题目输入

4

题目输出

****
*  *
*  *
****

C++解答

#include<iostream>

using namespace std;

void Rectangle(int);

int main()
{
	int a;
	cin >> a;
	Rectangle(a);

	return 0;
}

void Rectangle(int a)
{
	for(int col=1; col<=a; col++)
	{
		cout << '*';
	}
	cout << endl;
	for(int row=2; row<=a-1; row++)
	{
		cout << '*';
		for(int col=2; col<=a-1; col++)
		{
			cout << ' ';
		}
		cout << '*' << endl;
	}
	for(int col=1; col<=a; col++)
	{
		cout<< '*';
	}
	cout << endl;
}
时间限制 1 秒
内存限制 128 MB
讨论 统计
上一题 下一题