current position:Home>C language and application file programming program

C language and application file programming program

2022-02-02 21:27:55 CSDN Q & A

Programming to read from the file 10 Yes m,k(m,k Are positive integers ), Find greater than m And close to m Of k prime number , And output the results to a file . For example, if you enter 17,5, The output of 19,23,29,31,37




Refer to the answer 1:
#include <stdio.h>void fun(int m, int k, int xx[]){    int i, j;    int p = 0;    for(i=m+1;i>m;i++)    {        for(j=2;j<i;j++)        {            if(i%j==0)            break;        }        if(j == i)        xx[p++] = i;        if(p>k)        break;    }}main(){   int m, n, zz[1000] ;   printf( "\nPlease enter two integers:") ;   scanf("%d%d", &m, &n ) ;   fun( m, n, zz) ;   for( m = 0 ; m < n ; m++ )   printf("%d ", zz[m]) ;   printf("\n") ;   }



Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022127535628.html

Random recommended