我这段代码哪有错???
namespace Test
{
class Program
{
static void Main(string[] args)
{
int x = 1;
int sum = 0;//和,初始化为0
while (x <= 30)//循环条件
{
if (x % 2 != 0)//筛选条件
sum = sum + x;
x++;
}
Console.Write("1-30奇数的和:"sum);
}
}
}
namespace Test
{
class Program
{
static void Main(string[] args)
{
int x = 1;
int sum = 0;//和,初始化为0
while (x <= 30)//循环条件
{
if (x % 2 != 0)//筛选条件
sum = sum + x;
x++;
}
Console.Write("1-30奇数的和:"sum);
}
}
}
2018-10-13
举报