题解 | KiKi求质数个数
KiKi求质数个数
https://www.nowcoder.com/practice/d3a404ee0f8d41f98bf4707035d91086
#include <stdio.h> #include <stdbool.h> bool IF_Z(int x) {//用于判断是否为质数 bool fol = 0; int i = 0; for (i = 2; i < x; i++) { if (x % i == 0) { fol = 1; break; } } if (!fol) { return true; } else { return false; } } int main() { int i = 0; int n = 0; for (i = 100; i < 1000; i++) { bool c = IF_Z(i); if (c) { n++; } } printf("%d", n); return 0; }