一个C#简单程序问题

来源:百度知道 编辑:UC知道 时间:2024/05/14 14:03:34
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
class Program
{
static void F()
{
int x = 1;
while (x <= 20)
{
Console.Write(x);
if (x % 5 == 0)
Console.WriteLine();
else
Console.Write("\t");
}
}

static void Main(string[] args)
{
F();

}
}

}

这个程序错哪了?,运行后屏幕上全是1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1

if (x % 5 == 0)
Console.WriteLine();
else
Console.Write("\t");
x++;//在这添行代码

x从头到尾都没变,肯定都是1了。
x++试试。

在while循环里加这个语句:
x++;
这样应该就行了~

Console.Write(x);
换成x++;