- 8
- 0
- 约2.36千字
- 约 8页
- 2021-01-20 发布于山东
- 举报
1、编写程序,求 1-3+5-7+ -99+101 的值。
参考编程序如下:
#include stdio.h
void main()
{ int i,s,t; i=1;s=0;t=1; while (i=101) { s=s+i* t;
i=i+2;
t=-t;
}
printf( %d\n,s);
}
1 1 1 1
e 1
2、编写程序,求 e 的值, 1! 2! 3! 4!
1)用 for 循环,计算前 50 项。
2)用 while 循环,要求直至最后的一项的值小于参考程序如下:
1)#include stdio.h
void main()
{ int i; float s,t; s=2.0;
。
10 6。
t=1.0;
for(i=1;i=48;i++)
{ t=t* (t+1); s=s+1/t;
}
printf( %f\n ,s);
}
2)#include stdio.h #include math.h void main()
{ float e,t,s; e=2.0;t=1.0;s=1.0; while(fabs(s)=1e-6) { t=t* (t+1);
s=1/t;
e=e+s;
}
printf( %f\n ,e);
}
3、编写程序,输出从公元 2000 年至 3000 年所有闰年的年号,每输
出 10 个年号换一行。判断公元年是否为闰年的
原创力文档

文档评论(0)