[HDU]2565放大的X

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

本来是想做个大水,放松一下的,没想到这题好诡异,PE了不下3次,

这题PE的主要原因不同其他题目,是隔行条件出错,是因为有些空格不要输出!!!!!

#include"stdio.h"
#include"stdlib.h"
int main()
{
    int t,n,i,j,x;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
            if(i<=n/2)
            x=n-i;
            else
            x=i+1;        
            for(j=0;j<x;j++)
            {
               if(j==i||j==n-i-1)  printf("X");
               else printf(" ");
            }
            printf("\n");
        }  
        //if(n>0)  
        printf("\n");  
    }
    return 0;
    //system("pause");
}

 

posted @ 2013-08-12 17:00  天际。  阅读(288)  评论(0编辑  收藏  举报