hdu2565

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

简单题:

i+j<n-1,是对图形的上半部分空格的控制。

i>j , 是对图形下半部分空格的控制。

View Code
#include"iostream"
using namespace std;
int main()
{
int t;
int n;
cin
>>t;
while(t--)
{
int i,j;
cin
>>n;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i==j||i+j==n-1) cout<<"X";
else if(i+j<n-1) cout<<" ";
else if(i>j) cout<<" ";
}
cout
<<endl;
}
cout
<<endl;
}
return 0;
}
posted @ 2011-04-27 08:49  聊聊IT那些事  阅读(314)  评论(0编辑  收藏  举报