20、给定程序MODI1.C中函数 fun 的功能是:计算并输出high以内最大的10个素数之和。high的值由主函数传给fun函数。
若high的值为: 100, 则函数的值为: 732。
请改正程序中的错误,使程序能输出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
#include #include int fun( int high )
{ int sum = 0, n=0, j, yes;
/************found************/
while ((high >= 2) && (n < 10)
{ yes = 1;
for (j=2; j<=high/2; j++ )
if (high % j ==0 ){
/************found************/
yes=0; break
}
if (yes) { sum +=high; n++; }
high--;
}
return sum ;
}
main ( )
{
printf("%d\n", fun (100));
}
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|