AcWing
  • 首页
  • 活动
  • 题库
  • 竞赛
  • 应用
  • 更多
    • 题解
    • 分享
    • 商店
    • 问答
    • 吐槽
  • App
  • 登录/注册

不知道为什么错了



0


题目链接 https://www.acwing.com/activity/content/problem/content/1887/

一直报wrong answer啊也看不出哪里有问题

错误的代码:

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        int x;
        cin>>x;
        bool y=true;
        for(int i=2;i<x;i++){
            if(x%i==0)
            y=false;
            break;
        }
        if(y)cout<<x<<" is prime"<<endl;
        else cout<<x<<" is not prime"<<endl;
    }
    return 0;
}

}


提问于16天前
kkbo
362


2 个问答



0

有用的话点个赞呗
代码

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        int x;
        cin>>x;
        if (x == 1) {
            puts ("1 is not prime");////////////
            continue;
        }
        bool y=true;
        for(int i=2;i<=x/i;i++){    //////////////////////
            if(x%i==0)
            y=false;
            break;
        }
        if(y)cout<<x<<" is prime"<<endl;
        else cout<<x<<" is not prime"<<endl;
    }
    return 0;
}

}
回答于9天前
incra
131235


0

1不是质数

回答于14天前
Errors
2866

我来回答
你确定删除吗?
1024
x

© 2018-2023 AcWing 版权所有  |  京ICP备17053197号-1
用户协议  |  隐私政策  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标
请输入绑定的邮箱地址
请输入注册信息