求大神用C#的for语句编写个图形,样子如下:

问题描述:

求大神用C#的for语句编写个图形,样子如下:
1
121
12321
1234321
12321
121
1

跪求了 谢谢
如果能输入数字 让他变大小的最好了 不行就做死的 再次感谢
1个回答 分类:综合 2014-10-01

问题解答:

我来补答
int x = 4;
for (int i = 0; i < 2 * x - 1; i++){
if (i < x) {
int y = 1;
for (int j = 0; j < 2 * x - 1; j++) {
if (y > 0) {
if (j < (x - i - 1)) {
Console.Write(" "); }
if (j >= (x - i - 1) && j < x - 1) {
Console.Write(y++); }
if (j >= x - 1) {
Console.Write(y--); } }
else {
Console.Write(" ");} }
Console.Write("\n");}
else {
int y = 1;
for (int j = 0; j < 2 * x - 1; j++){
if (y > 0){
if (j < (i - x + 1)) {
Console.Write(" "); }
if (j >= (i - x + 1) && j < x-1) {
Console.Write(y++); }
if (j >= x-1) {
Console.Write(y--);}}
else {
Console.Write(" ");} }
Console.Write("\n"); }}
 
 
展开全文阅读
剩余:2000
下一页:fx的解析式