究竟哪里出错了?
查看原帖
究竟哪里出错了?
187053
1z0m6tyghvbwyx楼主2020/7/23 21:41
#include<bits/stdc++.h>
using namespace std;
int a[1001],n,k=0;
bool pd(int q)
{
	int k=2;
	int i=q;
	while(k<=floor(sqrt(i))&&(i%k!=0))
		k++;
	if(k>floor(sqrt(i)))
		return true;
	else
		return false;
}
int dfs(int x,int y)
{
	if(pd(x)==true&&pd(y)==true)
		cout<<x+y<<"="<<x<<"+"<<y<<endl;
	else
		dfs(x++,y--);
}
int main()
{
	cin>>n;
	for(int i=4;i<=n;i++)
	{
		if(i%2==0)
			k++;
	}
	for(int i=4;i<=n;i++)
	{
		if(i%2==0)
		for(int j=1;j<=k;j++)
		{
			a[j]=i;
			dfs(2,a[j]-2);
		}	
	}
}
2020/7/23 21:41
加载中...