C# 有人能帮我做这个简单的For循环吗? /*编写一个程序,询问用户 *输入起点和终点的步骤 *计数范围的点和 *增量值并显示总计 *在这个范围内的数字有多少 */ int启动; 内端; 整数增量; 整数和=0; 整数计数=0; Console.WriteLine(“输入起始编号”); start=Int32.Parse(Console.ReadLine()); Console.WriteLine(“输入结束编号”); end=Int32.Parse(Console.ReadLine()); Console.WriteLine(“输入增量编号”); increment=Int32.Parse(Console.ReadLine()); 对于(start=;end

C# 有人能帮我做这个简单的For循环吗? /*编写一个程序,询问用户 *输入起点和终点的步骤 *计数范围的点和 *增量值并显示总计 *在这个范围内的数字有多少 */ int启动; 内端; 整数增量; 整数和=0; 整数计数=0; Console.WriteLine(“输入起始编号”); start=Int32.Parse(Console.ReadLine()); Console.WriteLine(“输入结束编号”); end=Int32.Parse(Console.ReadLine()); Console.WriteLine(“输入增量编号”); increment=Int32.Parse(Console.ReadLine()); 对于(start=;end,c#,for-loop,C#,For Loop,您希望在startend时进行循环,并且每次满足该条件时,计数器都会递增增量 这就是循环的结构: /* Write a program that asks the user * to enter the starting point and end * point of the counting range and the * increment value and displays the total * of the numbers within that range */

您希望在
start
end时进行循环,并且每次满足该条件时,计数器都会递增
增量

这就是循环的结构:

/* Write a program that asks the user
 * to enter the starting point and end
 * point of the counting range and the 
 * increment value and displays the total 
 * of the numbers within that range
 */

int start;
int end;
int increment;
int sum = 0;
int count= 0;

Console.WriteLine(" Enter the start number ");
start = Int32.Parse(Console.ReadLine());

Console.WriteLine(" Enter the end number ");
end = Int32.Parse(Console.ReadLine());

Console.WriteLine(" Enter the increment number ");
increment = Int32.Parse(Console.ReadLine());

for ( start = ; end <= start ; count = count + increment  )
{

    Console.WriteLine(" Number is: " + count);

}

Console.WriteLine(" Sum is: " + sum);
Console.ReadKey();
for(int i=start;i
您希望在
开始时执行循环
结束,并且每次满足该条件时,计数器都会以
增量
递增

这就是循环的结构:

/* Write a program that asks the user
 * to enter the starting point and end
 * point of the counting range and the 
 * increment value and displays the total 
 * of the numbers within that range
 */

int start;
int end;
int increment;
int sum = 0;
int count= 0;

Console.WriteLine(" Enter the start number ");
start = Int32.Parse(Console.ReadLine());

Console.WriteLine(" Enter the end number ");
end = Int32.Parse(Console.ReadLine());

Console.WriteLine(" Enter the increment number ");
increment = Int32.Parse(Console.ReadLine());

for ( start = ; end <= start ; count = count + increment  )
{

    Console.WriteLine(" Number is: " + count);

}

Console.WriteLine(" Sum is: " + sum);
Console.ReadKey();
for(int i=start;i
我稍微修改了一下您的代码

for (int i = start; i < end; i += increment) 
{
    // Add to total and display current value
}
/*编写一个程序,询问用户
*输入起点和终点的步骤
*计数范围的点和
*增量值并显示总计
*在这个范围内的数字有多少
*/
int启动;
内端;
整数增量;
整数和=0;
整数计数=0;
Console.WriteLine(“输入起始编号”);
start=Int32.Parse(Console.ReadLine());
Console.WriteLine(“输入结束编号”);
end=Int32.Parse(Console.ReadLine());
Console.WriteLine(“输入增量编号”);
increment=Int32.Parse(Console.ReadLine());
for(count=start;//count的初始值

count我稍微修改了你的代码

for (int i = start; i < end; i += increment) 
{
    // Add to total and display current value
}
/*编写一个程序,询问用户
*输入起点和终点的步骤
*计数范围的点和
*增量值并显示总计
*在这个范围内的数字有多少
*/
int启动;
内端;
整数增量;
整数和=0;
整数计数=0;
Console.WriteLine(“输入起始编号”);
start=Int32.Parse(Console.ReadLine());
Console.WriteLine(“输入结束编号”);
end=Int32.Parse(Console.ReadLine());
Console.WriteLine(“输入增量编号”);
increment=Int32.Parse(Console.ReadLine());
for(count=start;//count的初始值


计算你的for循环是不正确的这里没有问题,只是一个家庭作业和一些代码。要清楚你遇到了什么,预期与实际的结果是什么,错误消息等。我准备在几天内测试循环,这是一个示例问题这是我得到的返回输入开始编号1输入第结束数字10输入增量数字2数字是:0总和是:0这是控制台窗口提示我的??你从来没有计算过总和!我对这一点完全不熟悉我只是看我的课堂讲稿,那里没有给出解决方案。你的for循环不正确这里没有问题,只有一个家庭作业和一些代码。Be cl听清楚你所遇到的困难,预期结果与实际结果,错误消息等。我准备在几天内进行循环测试,这是一个示例问题这是我得到的反馈输入开始数字1输入结束数字10输入增量数字2数字是:0总和是:0这是控制台窗口所支持的返回给我??你从来没有计算过总数!我对这一点完全不熟悉我只是在看我的课堂讲稿,没有给出解决方案。输入开始数字1输入结束数字10输入递增数字2数字是:0总和是:0这是控制台窗口提示我的??不要在循环。循环应该是
for(int count=start;count
。当然,总和不会自动计算。因为它从未更改,所以它保持为0。输入起始数字1输入结束数字10输入增量数字2数字是:0总和是:0这是控制台窗口提示我的??不要在循环之前声明
计数
。循环应该是
的(整数计数=开始;计数<结束;计数+=增量)
。当然,总和不会自动计算。因为它从未更改,所以它保持为0。这似乎起作用了!谢谢!另外,您可以解释for语句吗?1.初始化计数=开始?2.保护…当计数小于结束时?3.取得进展…计数=计数+增量我尝试解释上述代码,但是t我认为最好研究细节tut这似乎有效!谢谢!另外,你能解释for语句吗?1.初始化计数=开始?2.保护…当计数小于结束?3.取得进展…计数=计数+增量我试图解释上述代码,但我认为最好研究细节tut