第五章 循环结构程序设计 4.编程题 (1)求下列式子的值。 #include stdio.h void main() { float sum,n,t1,t2; sum=0;n=1; while(n=100) { t1=1/n; t2=-1/(n+1); sum=sum+t1+t2; n=n+2; } printf(%f\n,sum); } 一次求两项 冤险饺矫阅檄虱浓殉鼻陪锰柱爽俘诛秦惰算烷咀烫舶噶想紊摸康壤扰偷恩河南理工大学C语言第五章课后习题答案河南理工大学C语言第五章课后习题答案 第五章 循环结构程序设计 4.编程题 (1)求下列式子的值。 void main( ) { float s, n, t1, t2; s=0; n=1; while(n100) { t1=1/n; t2=-1/(n+1); s=s+t1+t2; n=n+2; } printf(%f,s); } #include stdio.h void main( ) { float s, n, t1, t2; s=1; n=1; t1=1; while(n100) { n++; t1=-t1; t2=t1/n; s+=t2; } printf(%f,s); } 砾纽珠
原创力文档

文档评论(0)