2019独角兽企业重金招聘Python工程师标准>>>

#include<iostream>
#include<sys/timeb.h>
using namespace std;int main()
{timeb t1, t2;long t;double x, sum, tsum;int n;cout << "type the value of x and n: ";cin >> x >> n;ftime(&t1);sum = 1;for (int i = 1; i <= n; i++){tsum = 1;for (int j = 1; j <= i; j++)tsum = tsum * (-1.0) / x;sum += tsum;}cout << "result1: " << sum << endl;ftime(&t2);cout << "elapsed time: " << (t2.time - t1.time) * 1000 + t2.millitm - t1.millitm << endl << endl;ftime(&t1);sum = 1, tsum = 1;for (int i = 1; i <= n; i++){tsum = tsum * (-1.0) / x;sum += tsum;}cout << "result2: " << sum << endl;ftime(&t2);cout << "elapsed time: " << (t2.time - t1.time) * 1000 + t2.millitm - t1.millitm << endl;cin.get();cin.get();return 0;
}

转载于:https://my.oschina.net/kuailechengxuyuan/blog/669431

102TimeStatistic相关推荐

最新文章

  1. JAVA 线上故障排查套路,从 CPU、磁盘、内存、网络到GC 一条龙!
  2. 【leetcode】944. Delete Columns to Make Sorted
  3. linux远程跳板机超时
  4. android子视图无菜单,Android 菜单详解
  5. php刷新onload(),JS页面刷新的方法总结
  6. Windows 7 添加SSD硬盘后重启卡住正在启动
  7. 农银电商项目学习笔记(一)
  8. zoj 3690(递推+矩阵优化)
  9. codeblocks下载安装及问题解决
  10. String intern()方法
  11. 朋友圈加粗字体数字_报名 | 零基础入门brush lettering英文花式字体
  12. Linux搭建泰拉瑞亚(原版/模组/插件)服务器之1.3模组服务器
  13. 数据分析-思维分析逻辑day04
  14. 劲牌连续两年问鼎全国质量大奖背后的密码
  15. Could not find a version of package tomorrow-sky/test matching your minimum-stability (stable)
  16. java aes 工具类_AESUtil Java AES 加密解密工具类
  17. Vue3 vue-cli、create-react-app、vite 创建vue/react项目(笔记)
  18. 【Practical】随机过程
  19. 移动端Chrome怎样才能一直保持桌面版网站呢?
  20. java魔方游戏代码_Java 3D魔方

热门文章

  1. 趋势型指标——MACD
  2. mkfs.ext4 /dev/sdb 与 mkfs.ext4 /dev/sdb1
  3. SSH远程会话管理工具 - screen使用教程
  4. asp.net .ashx文件使用server.mappath解决方法
  5. .Net Core使用视图组件(ViewComponent)封装表单文本框控件
  6. 95E Lucky Country
  7. pgpool-II的性能缺陷(二)
  8. centos7 搭建nfs共享文件
  9. 笨办法学 Python · 续 第五部分:文本解析
  10. BeautifulSoup安装及其应用