题目描述
Print a Frame
Draw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.
##########
#........#
#........#
#........#
#........#
##########
输入
The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.
The input ends with two 0 (when both H and W are zero).
输出
For each dataset, print the frame made of ‘#’ and ‘.’.
Print a blank line after each dataset.
题解
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
while(scanf("%d %d",&a,&b)!=EOF)
{
if(a==0&&b==0)
break;
for(int i=1;i<=a;i++)
{
if(i==1||i==a)
{
for(int j=0;j<b;j++)
{
cout<<"#";
}
cout<<endl;
}
else
{
for(int j=1;j<=b;j++)
{
if(j==1||j==b)
cout<<"#";
else
cout<<".";
}
cout<<endl;
}
}
cout<<endl;
}
return 0;
}