博客
关于我
浙大版《C语言程序设计(第3版)》题目集 练习2-15
阅读量:118 次
发布时间:2019-02-26

本文共 642 字,大约阅读时间需要 2 分钟。

?????????N???????????????????????????3?????????????????????????????????????????????N????N????????????????????

????

#include 
#include
int main() { int n; double sum = 0.0; int d = 1; if (scanf("%d", &n) == 1) { for (int i = 1; i <= n; i++) { double sign = (i % 2 == 1) ? 1.0 : -1.0; sum += sign * (1.0 / d); d += 3; } printf("sum = %.3f", sum); } return 0;}

????

  • ???????scanf???????N?
  • ??????sum?????N????d????1??????????
  • ??????1???N?????????
    • ???????????????????
    • ???????????sum??
    • ????d????3?
  • ??????sum??????????????
  • ??????????????????????????????N??

    转载地址:http://cvzu.baihongyu.com/

    你可能感兴趣的文章
    Python | 爬虫实战——亚马逊搜索页监控(附详细源码)
    查看>>
    python | 高效使用Python工具自动生成模块文档的秘诀
    查看>>
    python 一个list去除另一个list中的值
    查看>>
    python 三大框架的 介绍。
    查看>>
    Python 下载的 11 种姿势,一种比一种高级!
    查看>>
    python读取一个文件夹下所有图片_初学Python-找出文件夹下的所有图片
    查看>>
    Python 中 3 个不可思议的返回功能
    查看>>
    python 中 dict 的另一种用法
    查看>>
    Python 中 PIL 读取图片出现异常旋转的解决方法
    查看>>
    python读取word表格内容(1)
    查看>>
    python 中os.path.join 双斜杠的解决办法
    查看>>
    python 中PIL.Image和OpenCV图像格式相互转换
    查看>>
    Python 中Semaphore 信号量对象、Event事件、Condition
    查看>>
    python 中with的使用及样例
    查看>>
    python读取wav文件并播放[pyaudio/wave]
    查看>>
    python读取txt文件的行数
    查看>>
    Python 中内置的最大堆 API
    查看>>
    Python 中只有一个 True 和一个 False 对象吗?
    查看>>
    python读取mtcars数据集并实现以下操作_关于数据处理。。,Python交流,技术交流区,鱼C论坛 - Powered by Discuz!...
    查看>>
    Python 中多线程与多处理之间的区别
    查看>>