开始学习循环。似乎这些事情会永远持续下去,因为我没有告诉它停止。问题是我不知道如何告诉它停止。我假设有一个声明,例如 != 但我真的不知道。
有人愿意解释循环如何停止吗?
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);
}
}
}
}
}