由于江苏常州OJ(http://oj.jzxx.net/)上有少数题目(这些题目具有二级链接)提交上去后不能查看程序,特建立本文集来存储这些题目的程序,以方便查阅。
题目:
http://oj.jzxx.net/problem.php?id=1201
程序:
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int i = n;
for(; i >= 1; i -= 2)
{
for(int k = 0; k < (n - i)/2; k++)
{
cout << ' ';
}
for(int j = i; j >= 1; j--)
{
cout << '*';
}
cout << endl;
}
i += 4; //i从-1变成3
for(; i <= n; i += 2)
{
for(int k = 0; k < (n - i)/2; k++)
{
cout << ' ';
}
for(int j = 1; j <= i; j++)
{
cout << '*';
}
cout << endl;
}
return 0;
}
TopCoder & Codeforces & AtCoder交流QQ群:648202993
更多内容请关注微信公众号
wechat_public_header.jpg
网友评论