#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h>
//#include<math.h> int is_prime(int n) { int i = 0; for (i = 2; i < n; i++)//可优化为i<=sqrt(n) { if (n % i == 0) return 0; } return 1; } int main() { int i = 0; int count = 0; for (i = 100; i<= 200; i++) { if (is_prime(i) == 1) { count++; } } printf("count= %d\n", count); system("pause\n"); return 0; }