C#的循环问题
如何用循环实现输出:1
2 3
4 5 6
7 8 9 10
2011-10-09 20:02
程序代码: int sum = 1;
for (int i = 1; i <= 4; i++)
{
for (int j = 1; j <= i; j++)
{
Console.Write(sum.ToString()+" ");
sum++;
}
Console.WriteLine();
}

2011-10-09 20:27
程序代码: int row = 1;
int col = 0;
for (int i = 1; i <= 10; i++)
{
Console.Write(i + " ");
col++;
if (row == col)
{
Console.WriteLine();
row++;
col = 0;
}
}
2011-10-09 20:36
2011-10-09 23:50
Console.Write(Enumerable.Range(1, 150).Aggregate("", (s, i) => s + i + (Math.Sqrt(1 + 8 * i) % 2 == 1 ? "\n" : "\t")));
2011-10-10 00:41
2011-10-10 08:33
2011-10-10 13:40
基础的东西还是自己去搞,多试几次就可以了!
2011-10-10 17:25
2011-10-13 00:28
基本最苦命
2011-10-13 18:39