解题思路:
                    (1).设置一个输入列数a,用于循环次数;

                    (2).设置一个用于保存的数列和的常量b,并且初始化b=0;            

                    举例:第一列:a=1,b+=2/1,分子是2,分母是1,

                            第二列:a=2,b+=3/2,分子是3,分母是2,

                            第三列:a=3,b+=5/3,分子是5,分母是3,

                            第四列,a=4,b+=8/5,分子是8,分母是5,

                        由此可知:

                                        (1).当分子第K项时,分母Z等于K-Z项.

                                        (2).当K进入下一项时候,肯定是当前K=K+Z(8/5,分子8=5+3)

                                        (3).分母Z=K-Z相当于这一次分子数K减去上一次分母数Z(8/5,分母5=8-3)

                    所以用一个循环来求出,i表示次数,每次循环,b都保存每次的值

注意事项:
                    
参考代码:

                楼主自己写的思路,可以供参考:

                        

                            

                                                    #include<stdio.h>
                                                    int main(void)
                                                    {
                                                             double a,b=0;                
                                                             double k=2.0,z=1.0;                 //注意精度
                                                             scanf("%lf",&a);                        //读取用户输入的次数
                                                             for(int i=0;i<a;i++)                      
                                                             {
                                                                          b=b+k/z;                        //b保存每一次的和
                                                                          k+=z;                            //为下一次分子K做准备
                                                                          z=k-z;                            //为下一次分母Z做准备
                                                              }
                                                              printf("%.2lf",b);                        //输出保留两位小数
                                                              return 0;
                                                      }

                            

    


                       有啥不懂的小伙伴可以在评论下方留言哦(づ ̄3 ̄)づ╭❤~O(∩_∩)O

点赞(0)
 

0.0分

0 人评分

C语言网提供由在职研发工程师或ACM蓝桥杯竞赛优秀选手录制的视频教程,并配有习题和答疑,点击了解:

一点编程也不会写的:零基础C语言学练课程

解决困扰你多年的C语言疑难杂症特性的C语言进阶课程

从零到写出一个爬虫的Python编程课程

只会语法写不出代码?手把手带你写100个编程真题的编程百练课程

信息学奥赛或C++选手的 必学C++课程

蓝桥杯ACM、信息学奥赛的必学课程:算法竞赛课入门课程

手把手讲解近五年真题的蓝桥杯辅导课程

评论列表 共有 0 条评论

暂无评论