c++20分求助

P5723 【深基4.例13】质数口袋

j不能从1开始,因为2%1=0,判断不成立
by czx6666 @ 2024-02-27 21:07:00


@[Kmeow](/user/1070491) 求关
by czx6666 @ 2024-02-27 21:07:30


弄个专门判断质数的函数
by czx6666 @ 2024-02-27 21:09:45


@[czx6666](/user/1056023) ```#include<stdio.h> #include<math.h> int main() { int n,sum=0,count=0; scanf("%d",&n); for(int i=2;;i++) { for(int x=1;x<=sqrt(i);x++) { if(i%x==0) break; else { printf("%d\n",i); count++; sum+=i; } } if(sum==n) break; } return 0; }``` 我这个代码哪里错了关注你了
by My3211215504 @ 2024-03-13 20:37:22


此已结 @[My3211215504](/user/962476)
by czx6666 @ 2024-03-14 16:52:58


|