香蕉视频app

香蕉视频appKeep on going never give up.

Let's Go

C#【練習】打印等腰三角形

C#Lonely2019-05-20 02:45:50244次0條

Console.Write("請輸入需要打印的等腰三角形行數:");
int x = int.Parse(Console.ReadLine());
for (int i = 1; i <= x; i++) //這個循環打印行數
{
    for (int j = 1; j <= x - i; j++) //這個循環打印空格
    {
        Console.Write(" "); 
    }
    for (int k = 1; k <= (i * 2 - 1); k++) //這個循環打印*號
    {
        Console.Write("*");
    }
    Console.WriteLine();
}
Console.ReadKey();

image.png


暗錨,解決錨點偏移

文章評論

    嘿,來試試登錄吧!