換行問題請教
我想達(dá)到的效果是:
123
1234
12345
但下面一段代碼輸出結(jié)果是:
123123412345
求問換行哪里有問題?
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? for(int y=1;y<=3;y++)
? ? ? ? ? ? for(int x=1;x<=y+2;x++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Console.Write(x);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? }
? ? ? ? ? ? ?Console.WriteLine();
? ? ? ? }
? ? }
}
2021-01-24
第一個(gè)for循環(huán)后面少了一個(gè){,所以下面換行的語句就沒起到作用
static void Main(string[] args)? {
? ? ? ? ? ?for (int y = 1; y <= 3; y++){
? ? ? ? ? ? ? ? for (int x = 1; x <= y+2; x++) {
? ? ? ? ? ? ? ? ? ? Console.Write(x);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine();
? ? ? ? ? ? ? ? ? }
? ? ? ? }
? ? }
}
2022-09-06
Console.WriteLine();改成?Console.Write();
2022-09-06
?Console.WriteLine();改成?Console.Write();