[恢]hdu 2074
2011-12-17 07:47:56
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2074
题意:中文。模拟。
代码:
# include <stdio.h>
# include <string.h>
char out[110][110] ;
void gao(int n, char a[2])
{
memset (out, 0, sizeof(out)) ;
if (n == 1){
putchar (a[0]) ;
puts ("") ;
return ;
}
int s = 0, t = n-1, tm, i, j ;
int flag = ((n+1)/2 + 1) % 2 ;
for (tm = 0 ; tm < (n+1)/2 ; tm++)
{
for (i = s ; i <= t ; i++)
for(j = s; j <= t ; j++)
out[i][j] = a[flag] ;
flag = !flag ;
s++, t-- ;
}
out[0][0] = out[0][n-1] = out[n-1][0] = out[n-1][n-1] = ' ' ;
for (i = 0 ; i < n ; i++)
puts (out[i]) ;
}
int main ()
{
int num, nCase = 1 ;
char ch[2];
while (~scanf ("%d %c %c%*c", &num, &ch[0], &ch[1]))
{
if (nCase++ != 1) printf ("\n") ;
gao(num, ch) ;
}
return 0 ;
}