1+2+3+...100不同的循环次数,相同的结果,为什么?
a的初始值分别为0与1,但结果都是5050,为什么?当a=0
int b = 0;
for (int a =0; a < 101; a++)
{
b = b+a;
}
Console.WriteLine("b={0}", b);
Console.ReadKey();
结果是
b=5050
-------------------------------------------------------
当a=1
int b = 0;
for (int a =1; a < 101; a++)
{
b = b+a;
}
Console.WriteLine("b={0}", b);
Console.ReadKey();
结果是
b=5050
-------------------------------------------------------------
求解惑