博客
关于我
浙大版《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 手写数字识别-1
    查看>>
    Python实现接口自动化测试库(JSON与Requests)详解
    查看>>
    Python 手写数字识别-3-sklearn中的几种算法
    查看>>
    python实现SSIM和MSSSIM计算 (附完整源码)
    查看>>
    Python 打开文件注意事项
    查看>>
    python 批量修改文件名_python windows下批量修改文件名
    查看>>
    Python 抓取网页乱码问题 以及EXCEL乱码
    查看>>
    python 抓取网页内容
    查看>>
    python 按照当前日期创建文件
    查看>>
    Python 接口并发测试详解
    查看>>
    Python 接口自动化 —— requests框架
    查看>>
    python 接口自动化数据结构(如列表、字典、元组)
    查看>>
    Python 接口自动化测试中的深拷贝与浅拷贝~
    查看>>
    Python 接口自动化测试中的高阶函数
    查看>>
    python 控制 cmd 命令行颜色
    查看>>
    Python 操作 Azure Blob Storage
    查看>>
    Python 操作 Excel 全攻略 | 包括读取、写入、表格操作、图像输出和字体设置
    查看>>
    Python 操作 JMeter 探索:pymeter 实操指南
    查看>>
    Python 操作 Redis
    查看>>
    Python 操作Mysql(PyMysql)
    查看>>