102TimeStatistic
2024-05-09 23:37:08
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相关推荐
最新文章
- JAVA 线上故障排查套路,从 CPU、磁盘、内存、网络到GC 一条龙!
- 【leetcode】944. Delete Columns to Make Sorted
- linux远程跳板机超时
- android子视图无菜单,Android 菜单详解
- php刷新onload(),JS页面刷新的方法总结
- Windows 7 添加SSD硬盘后重启卡住正在启动
- 农银电商项目学习笔记(一)
- zoj 3690(递推+矩阵优化)
- codeblocks下载安装及问题解决
- String intern()方法
- 朋友圈加粗字体数字_报名 | 零基础入门brush lettering英文花式字体
- Linux搭建泰拉瑞亚(原版/模组/插件)服务器之1.3模组服务器
- 数据分析-思维分析逻辑day04
- 劲牌连续两年问鼎全国质量大奖背后的密码
- Could not find a version of package tomorrow-sky/test matching your minimum-stability (stable)
- java aes 工具类_AESUtil Java AES 加密解密工具类
- Vue3 vue-cli、create-react-app、vite 创建vue/react项目(笔记)
- 【Practical】随机过程
- 移动端Chrome怎样才能一直保持桌面版网站呢?
- java魔方游戏代码_Java 3D魔方
热门文章
- 趋势型指标——MACD
- mkfs.ext4 /dev/sdb 与 mkfs.ext4 /dev/sdb1
- SSH远程会话管理工具 - screen使用教程
- asp.net .ashx文件使用server.mappath解决方法
- .Net Core使用视图组件(ViewComponent)封装表单文本框控件
- 95E Lucky Country
- pgpool-II的性能缺陷(二)
- centos7 搭建nfs共享文件
- 笨办法学 Python · 续 第五部分:文本解析
- BeautifulSoup安装及其应用