![]() ![]() |
|
高校等考试题天天练二级C]10月30 | |
作者:佚名 文章来源:不详 点击数 更新时间:2008/4/18 14:36:13 文章录入:杜斌 责任编辑:杜斌 | |
|
|
以下程序的功能是计算并输出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)); } |
|
![]() ![]() |