Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
70827 文 13判断质数 C++ Accepted 1 MS 272 KB 420 2024-04-20 09:55:51

Tests(10/10):


Code:

#include<iostream> using namespace std; /** * */ int main(){ int n; cin>>n; bool flag=true; //true表示n是一个质数,反之为false for(int i=2;i<n;i++) { //判断n有没有除了1和它本身之外的因子 if(n%i==0){ //如果有其他因子 flag=false; break; } } if(flag && n!=1){ //true cout<<"Yes"<<endl; } else { cout<<"No"<<endl; } return 0; }