打印直角三角形4个,打印菱形
Posted 凌零聆
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了打印直角三角形4个,打印菱形相关的知识,希望对你有一定的参考价值。
for (int i = 1; i <= 6; i++) { for (int a = 1; a <= i; a++) { Console.Write("☆"); } for (int b = 1; b <= 12 - 2 * i + 1; b++) { Console.Write(" "); } for (int c = 1; c <= i; c++) { Console.Write("☆"); } Console.Write("\n"); } Console.Write("\n"); for (int i = 1; i <= 6; i++) { for (int a = 1; a <= 6 - (i - 1); a++) { Console.Write("☆"); } for (int b = 1; b <= 2 * (i - 1) + 1; b++) { Console.Write(" "); } for (int c = 1; c <= 6 - (i - 1); c++) { Console.Write("☆"); } Console.Write("\n"); } Console.Write("\n"); for (int i = 1; i <= 6; i++) { for (int e = 1; e <=6 - i; e++) { Console.Write(" "); } for (int f = 1; f <=( 2 * i - 1); f++) { Console.Write("▲"); } Console.Write("\n"); } for (int i = 1; i <= 6; i++) { for (int e = 1; e <=i; e++) { Console.Write(" "); } for (int f = 0; f < 2 * (6 - i) - 1; f++) { Console.Write("▲"); } Console.Write("\n"); }
以上是关于打印直角三角形4个,打印菱形的主要内容,如果未能解决你的问题,请参考以下文章