90求助 第7个WA了
查看原帖
90求助 第7个WA了
919054
nanfengguojing楼主2023/2/24 23:42
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
typedef struct fs{
	int a;
	string b;
}fs;
int main(){
	int n,temp=2,sum=0;
	cin>>n;
	for(int i=2;i<n;i++){
		bool flag=1;
		for(int j=2;j<=sqrt(i);j++){
			if(i%j==0){
				flag=0;
				break;
			}
		}
		if(flag==1){
			if(i-temp==2){
				sum++;
				cout<<temp<<" "<<i<<endl;
			}
			temp=i;
		}
	}
	if(sum==0){
		cout<<"empty";
	}
	return 0;
}
2023/2/24 23:42
加载中...