小编Mic*_*han的帖子

C# 新手,无法更新 for 循环中的变量

在撰写本文时,我大约花了 2 个小时学习 C#(以及一般编程),我正在尝试编写一个简单的程序来帮助我的儿子学习将两位数相加。我拥有的是

//Creating needed variables    
using System.Data.Common;

int num1, num2, answer, numCorrect, numIncorrect, question;
String userAnswer;
Random random = new Random();
numCorrect = 0;
numIncorrect = 0;

//Looping the question for 10 rounds
for (question = 0; question < 11; question++)
{
    //Defining Numbers
    ;
    num1 = random.Next(1, 100);
    num2 = random.Next(1, 100); 

    //The Problem
    Console.WriteLine(num1 + "+" + num2 + "= ?");
    userAnswer = Console.ReadLine();
    answer = Convert.ToInt32(userAnswer);

    //Logic that will provide the ansewer.
    if (answer == …
Run Code Online (Sandbox Code Playgroud)

c# for-loop

0
推荐指数
1
解决办法
180
查看次数

标签 统计

c# ×1

for-loop ×1