信息学奥赛一本通答案dj哥德巴赫猜想1157

#include<iostream>
using namespace std;
bool isPrime(int x)
{
	if(x<2) return false;
	for(int i=2;i*i<=x;i++)
	{
		if(x%i==0) return false;
	}
	return true;
}
void divid(int x)
{
	cout<<x<<"=";
	for(int i=2;i<=x/2;i++)
	{
		int i2=x-i;
		if(isPrime(i)&&isPrime(i2))
		{
			cout<<i<<"+"<<i2<<endl;
			return ;
		} 
	}
}
int main()
{
	for(int i=6;i<=100;i+=2)
	{
		divid(i);
	}
	return 0;
}

想要其他题目答案,黑客小程序,或c++基础的,关注我。

求点赞!

猜你喜欢

转载自blog.csdn.net/m0_73220913/article/details/129801940
今日推荐