打印输出范围内素数的个数有多少,采用C编程语言方式的实现

Problem Description
Give you a lot of positive integers, just to find out how many prime numbers there are.

Input
There are a lot of cases. In each case, there is an integer N representing the number of integers to find. Each integer won’t exceed 32-bit signed integer, and each of them won’t be less than 2.

Output
For each case, print the number of prime numbers you have found out.

Sample Input
3
2 3 4

Sample Output
2

只会java的,应该差不多吧

Scanner sc = new Scanner(System.in);
        System.out.println("输入起始:");
        int beginNum = sc.nextInt();
        System.out.println("输入结束:");
        int endNum = sc.nextInt();
        if(endNum>beginNum)
        {
            for(int i = beginNum;i<=endNum;i++)
            {
                boolean isPrime = true;
                for(int j = 2;j<=Math.sqrt(i);j++)
                {
                    if(i%j==0)
                    {
                         isPrime = false;
                         break;
                    }
                }
                if(isPrime)
                {
                    System.out.println(i);
                }
            }
        }
#include <stdio.h>
#include<iostream>

using namespace std;

int isPrime(int a[],int len){
    int i, j,count=0;
    for (i = 0; i < len; i++){
        int isprime = 1;
        if (a[i] == 1){   //1不是素数
            isprime = 0;
            continue;;
        }
        for (j = 2; j < a[i]; j++){     
            if (a[i] % j == 0){
                isprime = 0;
                break;
            }
        }
        if (isprime ==1)
        {
            count++;
        }

    }
    return count;
}
void main(){
    int i,j;
    scanf_s("%d", &i);
    int a[100] = {0};
    int num=0;
    while (scanf_s("%d", &a[num]) != EOF && getchar() != '\n') num++;

    printf("\n");

    printf("%d", isPrime(a,i));

}