C 练习实例24

C 语言教程 · 2019-02-21 17:59:24

题目:有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和。

程序分析:请抓住分子与分母的变化规律。

程序源代码:

实例

// Created by www.codercto.com on 15/11/9. // Copyright © 2015年 码农教程. All rights reserved. // #include <stdio.h> int main() { int i,t; float sum=0; float a=2,b=1; for(i=1;i<=20;i++) { sum=sum+a/b; t=a; a=a+b; b=t; } printf("%9.6f\n",sum); }

以上实例输出结果为:

32.660263

点击查看所有 C 语言教程 文章: https://www.codercto.com/courses/l/17.html

查看所有标签

Web Analytics

Web Analytics

Avinash Kaushik / Sybex / 2007-6-5 / USD 29.99

在线阅读本书 Written by an in-the-trenches practitioner, this step-by-step guide shows you how to implement a successful Web analytics strategy. Web analytics expert Avinash Kaushik, in his thought-p......一起来看看 《Web Analytics》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

MD5 加密
MD5 加密

MD5 加密工具

html转js在线工具
html转js在线工具

html转js在线工具