文章

83

粉丝

2

获赞

592

访问

63.9k

头像
判断素数 题解:
P1013 贵州大学机试题
发布于 2026年3月
阅读数 886

#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;
}

int main(){
	int n;
	cin >> n;
	
	while(!isPrime(n)){
		n++;
		}
	cout << n;
	
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发