Find the middle of prime numbers

// Find all primes between two integers (including both integers), the result is stored in the array bb, the function returns the number of prime numbers.
// For example, the input 6 and 21, the output is: 711,131,719. 

#include <stdio.h> 
#include <stdlib.h> 
 #define N 1000
 int Fun ( int n-, int m, int BB [N]) {
     int I, J, K = 0 , In Flag;
    
    for(j=n;j<=m;j++) {
          flag=1;   
        for(i=2;i<j;i++)
            if(j%i==0) {  
               flag=0;
               break;
        }
        if(flag==1) 
           bb[k++]=j;
    }
    return k;
}

int main(){
    int n=0,m=0,i,k,bb[N];
    
    scanf("%d",&n);
    scanf("%d",&m);
    
    for(i=0;i<m-n;i++)
        bb[i]=0;
        
    k=fun(n,m,bb); 
    
    for(i=0;i<k;i++)
        printf("%4d",bb[i]);
    
    system("pause");
        
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/201qx/p/11968126.html