LeeBlog

导航

HDU 2052 Picture

    这题水就不用说了 只是要注意在控制高和宽的时候都要加2

代码
#include <stdio.h>
void print ( int width,int height )
{
for ( int i = 1; i <= height + 2; ++i )
{
for ( int j = 1 ; j <= width + 2 ; ++j )
if ( ( i == 1 || i == height +2 ) )
if ( j == 1 || j == width +2 )
printf (
"+" );
else
printf (
"-" );
else
if ( j == 1 || j == width + 2 )
printf (
"|" );
else
printf (
" " );
puts (
"" );
}
puts (
"" );
}
int main ( )
{
int width,height;
while ( scanf ( "%d%d" , &width, &height ) != EOF )
print ( width,height );
return 0;
}

 

posted on 2011-01-29 14:10  LeeBlog  阅读(231)  评论(0编辑  收藏  举报