高校等考试题天天练二级C]10月30 |
|
www.nanhushi.com 佚名 不详 |
知识点:素数求和运算 以下程序的功能是计算并输出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)); }
|
|
|
文章录入:杜斌 责任编辑:杜斌 |
|
上一篇文章: 高校等考试题天天练二级C]10月28日 下一篇文章: 高校等考试题天天练二级C]11月2日 |
【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|
|