以下程序的功能是计算并输出high以内最大的10个素数之和,high由主函数传给fun函数,例如:high的值为100,则函数的值为732。
#include
#include
#include
int fun( int high )
{ int sum = 0, n=0, j, yes;
while (high >= 2 && n < 10)
{ yes = 1;
for (j=2; j<=high/2; j )
if [ (10) ]
{yes=0; [ (11) ];}
if (yes)
{ sum =high; n ; }
high--;
}
[ (12) ];
}
main ( )
{ clrscr( );
printf("%dn", fun (100));
}
