class Program
{
static void Main(string[] args)
{
for (int y = 1; y <= 7; y++)
{
for (int x = 1; x <= y; x++)
{
Console.Write(x);
}
}
}
}
需要把最后一句輸出去掉
{
static void Main(string[] args)
{
for (int y = 1; y <= 7; y++)
{
for (int x = 1; x <= y; x++)
{
Console.Write(x);
}
}
}
}
需要把最后一句輸出去掉
2017-08-08
這個在線驗證的條件驗證的是橫向輸出,縱向輸出會報錯。
x +""意思就是變量后添加一個空格符,也可以寫成 x + ''
x +""意思就是變量后添加一個空格符,也可以寫成 x + ''
2017-08-08
注意是Console.Write(x+" ");而不是Console.WriteLine(x+" "); 每次都是這個出錯,真的是醉了
2017-08-08
確保y的值是0 即可,可以對2取余或者y-=2.但是如果取余應該是y%=2,而不是直接y%2。因為新的計算結果沒有賦值(即y并未接收新的數值),以上需要注意即可。
2017-08-08
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 7; j++ )
{
if (i == j || i + j == 6) {
Console.Write("o");
} else {
Console.Write(".");
}
}
Console.WriteLine();
}
哪位大神能翻譯下這段代碼的意思
{
for (int j = 0; j < 7; j++ )
{
if (i == j || i + j == 6) {
Console.Write("o");
} else {
Console.Write(".");
}
}
Console.WriteLine();
}
哪位大神能翻譯下這段代碼的意思
if (x >= y)
{if (x >= 5)
Console.WriteLine("5");}
else
if (y >= 6)
Console.WriteLine("6");
else
Console.WriteLine("7");
}
}
}
{if (x >= 5)
Console.WriteLine("5");}
else
if (y >= 6)
Console.WriteLine("6");
else
Console.WriteLine("7");
}
}
}
2017-08-07