我正在尝试在 C# 中解决 Project Euler 问题 #4。我遇到的问题是,当代码运行时,控制台窗口会短暂出现然后消失。我不知道问题可能是什么,因为我对编程比较陌生。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 1000; i > 100; i--)
for (int j = 1000; j > 100; j--)
PalCheck(i * j);
}
static void PalCheck(int original)
{
var reversed = new string(Convert.ToString(original).ToCharArray().Reverse().ToArray());
if (Convert.ToString(original) == reversed)
Console.WriteLine(original);
Console.ReadKey();
}
}
}