為什么提交之后沒反應(yīng),而如果有明顯錯(cuò)誤的話會(huì)報(bào)錯(cuò)
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? for (int x=1;x<=7;x++)//請完善代碼
? ? ? ? {
? ? ? ? ? ? for (int y=1;x<=7;y++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (x+y==8||x==y)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Console.Write("O");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Console.Write(".");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.WriteLine();
? ? ? ? }
? ? ? ? }
? ? }
}
2022-08-15
?for (int y=1;x<=7;y++)
這里第二個(gè)循環(huán)條件錯(cuò)了,把x改為y即可,設(shè)置為x就會(huì)讓第二層循環(huán)沒辦法跳出循環(huán)造成死循環(huán)。