⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vc0202.cpp

📁 VC面向对象的学习教程
💻 CPP
字号:
//example 2-2 
#include <iostream.h>
#define M 10001
void CreatePrimeList(int PrimeList[])
{
	int i,j;
	for(i=0;i<M;i=i+1)
		PrimeList[i]=i;
	i=2;
	while(i<M/2)
	{
		for(j=i+1;j<M;j=j+1)
			if(PrimeList[j]!=0&&PrimeList[j]%PrimeList[i]==0)
				PrimeList[j]=0;
		i=i+1;
		while(PrimeList[i]==0)
			i=i+1;
	}
}

int NextPrimeNumber(int p,int PrimeList[])
{
	p=p+1;
	while(PrimeList[p]==0)
		p=p+1;
	return PrimeList[p];

}

void main()
{
	int PrimeList[M];
	int x,p;
	CreatePrimeList(PrimeList);
	x=4;
	while(x<M)
	{
		p=PrimeList[2];
		while(p<M/2&&PrimeList[x-p]==0)
			p=NextPrimeNumber(p,PrimeList);
		if(p>=M/2)
			cout<<"Great Discovery"<<endl;
		else 
			cout<<"The even number"<<x<<"="<<p<<"+"<<x-p<<endl;
		x=x+2;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -