c语言实验报告。1000以内最大的10个素数以及求和
C语言程序
设计
领导形象设计圆作业设计ao工艺污水处理厂设计附属工程施工组织设计清扫机器人结构设计
实验报告
实验名称 循环控制语句
学 院 材料与冶金学院 专业班级 新能源1101 姓 名 汪爽 学 号 20110558
任课教师 柳秀梅 实验时间 2011年10月13日
1 实验目的
(1)熟练掌握while语句、do-while语句和for语句格式及使用方法,掌握三种
循环控制语句的循环过程以及循环结构的嵌套,利用三种循环语句实现循环结
构;
(2)掌握简单、常用的算法,并在编程过程中体验各种算法的编程技巧;
(3)进一步学习调试程序,掌握语法错误和逻辑错误的检查方法。
2 实验
内容
财务内部控制制度的内容财务内部控制制度的内容人员招聘与配置的内容项目成本控制的内容消防安全演练内容
输出1000以内的最大10个素数以及它们的和。
3 算法描述
流程
快递问题件怎么处理流程河南自建厂房流程下载关于规范招聘需求审批流程制作流程表下载邮件下载流程设计
图
a few members of the team cadres quality is not strong, a lot of things a few leading cadres as muddle along; wind float, in the specific work not burden, dare not touch, in the work "Dragonfly" phenomenon, keen to engage in formalism, do not further, not specious writing, seek practical results, sense of responsibility is not strong. Such as production safety supervision and management work, the strict requirements, heavy task, individual
开始
声明变量k,m,i=2,a[n],s=0,m=999,n=1;
k=sqrt(m) m=m-2
是
m%i=0,
否
i=i+1
是 i<=k?
否
是 n<=10a[n]=m, n=n+1
?
否
n=1
s=s+a[n]
n=n+1
是
n<10?
否
输出
s=a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+
a[8]+a[9]+a[10]
结束 a few members of the team cadres quality is not strong, a lot of things a few leading cadres as muddle along; wind float, in the specific work not burden, dare not touch, in the work "Dragonfly" phenomenon, keen to engage in formalism, do not further, not specious writing, seek practical results, sense of responsibility is not strong. Such as production safety supervision and management work, the strict requirements, heavy task, individual
4 源程设计
#include
#include main()
{
int m,i,k,a[10],n=1,s=0;
for(m=999;;m=m-2) {
k=(int)sqrt(m);
for(i=2;i<=k;i++)
if(m%i==0)
break;
if(i>=k+1)
{a[n]=m;
n++;
s=s+m;
}
if(n>=11)
break;
}
printf("%d+%d+%d+%d+%d+%d+%d+%d+%d+%d=%d\n",
a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],s);
}
5 测试数据
1000
6 运行结果
a few members of the team cadres quality is not strong, a lot of things a few leading cadres as muddle along; wind float, in the specific work not burden, dare not touch, in the work "Dragonfly" phenomenon, keen to engage in formalism, do not further, not specious writing, seek practical results, sense of responsibility is not strong. Such as production safety supervision and management work, the strict requirements, heavy task, individual
7 出现问题及解决方法
(1)对c语言编程不熟练,导致编程很是困难,经过认真地学习课本的内容和做实验后编程有 所改善。
(2)实验的过程中会忘记声明变量,得认真地检查发现问题。
(3)判断素数的程序编写错误,在同学的帮忙下得以解决。
.8实验心得
(1) 通过实验我对c语言的编程语言更加熟悉,加快编程输入语言的速度。 (2) 对for语句格式及使用方法了解的清楚了点,掌握三种循环控制语句的循
环过程以及循环结构的嵌套,利用三种循环语句实现循环结构。 (3) 再次让我明白做实验时要细心,认真检查。
a few members of the team cadres quality is not strong, a lot of things a few leading cadres as muddle along; wind float, in the specific work not burden, dare not touch, in the work "Dragonfly" phenomenon, keen to engage in formalism, do not further, not specious writing, seek practical results, sense of responsibility is not strong. Such as production safety supervision and management work, the strict requirements, heavy task, individual