#include using namespace std;//使用命名空间stdint main(int argc, char* argv[]){ float s,z1=2,z2=3,m1=1,m2=2,t; int i; s=z1/m1+z2/m2;//数列前两项之和 for (i = 0; i<13; i++) {//for循环计算剩余13项之和
t=m2;
m2+=m1;//计算当前项分母
m1=t;
t=z2;
z2+=z1; //计算当前项分子
z1=t;
s+=z2/m2; //累加项 } cout<<s<<endl;//输出最终结果 return 0; } |