高校等考试题天天练二级C]10月30
知识点:素数求和运算
以下程序的功能是计算并输出high以内最大的10个素数之和,high由主函数传给fun函数,例如:high的值为100,则函数的值为732。
#include <conio.h>
#include <stdio.h>
#include <math.h>
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("%d\n", fun (100));
}