Skip to content

Latest commit

 

History

History
42 lines (37 loc) · 506 Bytes

84.md

File metadata and controls

42 lines (37 loc) · 506 Bytes

题目:一个偶数总能表示为两个素数之和。

#include<stdio.h>
#include <math.h>

int ver(int num)
{
	for (int i = 2; i <= sqrt(num); ++i)
	{
		if (num % i == 0)
		{
			return 0;
		}
	}
	return 1;

}

int main()
{
	int n;
	scanf("%d", &n);

	if (n % 2 != 0 || n == 2)
	{
		printf("请输入一个大于2的偶数!\n");
	}
	else
	{
		for (int i = 2; i < n; ++i)
		{
			if (ver(i) && ver(n - i))
			{
				printf("%d = %d + %d\n", n, i, n - i);
				return 0;
			}
		}
	}

	return 0;
}