计算并输出high以内最大的十个素数的和。high的值由主函数传给fun函数


#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 (high % j ==0 ){
yes=0; break;
}
if (yes) { sum +=high; n++; }
high--;
}
return sum ;
}

main ( )
{
printf("%d\n", fun (100));
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM