61,658
社区成员




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static bool IsPrime(int n)
{
if (n == 2) return true;
for (int i = 2; i < Math.Sqrt((double)n) + 1; i++)
{
if (n % i == 0) return false;
}
return true;
}
static void Main(string[] args)
{
int n = 0;
while (n <= 2 || n % 2 != 0)
{
Console.Write("输入一个大于2的偶数:");
try
{
n = Convert.ToInt32(Console.ReadLine());
}
catch { }
}
for (int i = 2; i <= n / 2; i++)
{
if (IsPrime(i) && IsPrime(n - i)) Console.WriteLine("结果:{0}+{1}={2}。", i, n - i, n);
}
}
}
}