開始瞭解循環。似乎這些事情永遠持續下去,因爲我沒有告訴它停止。問題是我不知道如何告訴它停止。我正在假設像!=這樣的陳述,但我真的不知道。如何結束循環
任何人都在意解釋循環如何停止?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication326
{
class Program
{
static void Main(string[] args)
{
bool triLoop = true;
while (triLoop)
{
Console.WriteLine("Please enter the first integer...");
int firstInt = int.Parse(Console.ReadLine());
Console.WriteLine("Please enter the second integer...");
int secondInt = int.Parse(Console.ReadLine());
Console.WriteLine("Please enter the third integer...");
int thirdInt = int.Parse(Console.ReadLine());
if ((firstInt + secondInt > thirdInt) && (secondInt + thirdInt > firstInt) && (firstInt + thirdInt > secondInt))
{
Console.WriteLine("The numbers {0}, {1}, and {2} CAN represent sides of the same triangle.", firstInt, secondInt, thirdInt);
}
else
{
Console.WriteLine("The numbers {0}, {1}, and {2} CANNOT represent the sides of the same triangle.", firstInt, secondInt, thirdInt);
}
}
}
}
}
我注意到你還沒有接受任何答案 - 如果這個問題的答案之一(或你發佈的其他答案)幫助你解決了你的問題,你可以點擊左邊的複選標記將其標記爲已接受文本(正下方的投票按鈕)。 – Michelle