1051: 字符图形7-星号菱形
Time Limit: 1 Sec Memory Limit: 128 MBDescription
输入一个整数打印字符图形
Input
一个整数(0<N<10)
Output
一个字符图形
Sample Input
2
Sample Output
□□×
□×××
×××××
□×××
□□×
HINT
□表示一个空格,×表示“*”号。
Source
#include<iostream>
using namespace std;
main()
{
int N;
cin>>N;
for(int i=0;i<N+1;i++)
{
for(int j=1;j<N-i+1;j++)
{cout<<' ';}
for(int k=1;k<=2*i+1;k++)
{cout<<'*';}
cout<<endl;
}
for(int i=N-1;i>=0;i--)
{
for(int j=1;j<N-i+1;j++)
{cout<<' ';}
for(int k=1;k<=2*i+1;k++)
{cout<<'*';}
cout<<endl;
}
}