2011-12-15 05:20:44
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2091
题意:中文,模拟。
mark:2B了,数组开成了50*50。。。wa了2次。
代码:
# include <stdio.h>
# include <string.h>
char g[50][100] ;
int main ()
{
char ch ;
int i, num, a, b ;
int flag = 0 ;
while (~scanf ("%c", &ch))
{
if (ch == '@') break ;
scanf ("%d", &num) ;
getchar () ;
memset(g, ' ', sizeof(g)) ;
a = b = num-1 ;
for (i = 0 ; i < num ; i++)
{
g[i][a] = g[i][b] = ch ;
g[i][b+1] = '\0' ;
a--, b++ ;
}
while (a != b) g[i-1][a++] = ch ;
if (flag == 0) flag = 1 ;
else puts ("") ;
for (i = 0 ; i < num ; i++)
puts (g[i]) ;
}
return 0 ;
}