2011-12-31 19:19:52

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2565

题意:中文,模拟。

代码:

# include <stdio.h>
# include <string.h>


char graph[100] ;


void output (int n)
{
int i ;
memset (graph, ' ', sizeof (graph)) ;
for (i = 0 ; i < n ; i++)
{
memset(graph, ' ', sizeof(graph)) ;
graph[i] = graph[n-1-i] = 'X' ;
if (i<n/2) graph[n-i] = '\0' ;
else graph[i+1] = '\0' ;
puts (graph) ;
}
}


int main ()
{
int T, x ;
scanf ("%d", &T) ;
while (T--)
{
scanf ("%d", &x) ;
output(x) ;
puts ("") ;
}
return 0 ;
}