📜  在 c# 中执行 while 循环 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:43.197000             🧑  作者: Mango

代码示例6
int sugar = 0;
int salt = 0;

do {
    bottle1.choose();
    bottle2.choose();
    if ((bottle1 == 'Sugar') && (bottle2 == 'Sugar'))
    {
        Console.Write("Sugar");
        sugar++;
    }
    else if ((bottle1 == 'Salt') && (bottle1 == 'Salt'))
    {
        salt++;
        Console.Write("Salt");
    }
    else
    {
        Console.Write("None");
    }
} while ((salt < 10) || (sugar < 10));