#include<stdio.h>
void fun(int m,int k,int x[])
{
	int i,j,count=0;
	for(i=m+1;count<k;i++)
	{
		for(j=2;j<i;j++)
			if(i%j==0 && i!=j)   //判断i是否是素数
				break;
			if(i==j)  // 如果i==j则表示i是素数
				x[count++]=i;
	}			
}
void main()
{
	int m,k,x[81];
	printf("please input a interger and quantity:");
	scanf("%d%d",&m,&k);
	fun(m,k,x);
	for(int i=0;i<k;i++)
		printf("%d\t",x[i]);
	printf("\n");
}
原文:https://www.cnblogs.com/-slz-2/p/11254311.html