题解 | #KiKi求质数个数#
KiKi求质数个数
http://www.nowcoder.com/practice/d3a404ee0f8d41f98bf4707035d91086
#include<stdio.h>
int main() {
int count = 0, val = 0;
for (int i = 100; i <= 999; i++) {
for (int j = 1; j <= i; j++) {
if (i % j == 0) {
val++;
}
}
if (val == 2) count++;
val = 0;
}
printf("%d", count);
return 0;
}
int main() {
int count = 0, val = 0;
for (int i = 100; i <= 999; i++) {
for (int j = 1; j <= i; j++) {
if (i % j == 0) {
val++;
}
}
if (val == 2) count++;
val = 0;
}
printf("%d", count);
return 0;
}