20171202做的题
来源:互联网 发布:可以配音的软件 编辑:程序博客网 时间:2024/06/04 00:30
精度!精度(精确到小树点后20位)
Description
如今是信息化社会,是数据大爆炸的时代,而与数据其中一个很重要的属性就是数据精度。所谓差之毫厘,谬以千里。在数据精度上便能充分体现。
1991年海湾战争中,爱国者导弹因截断误差导致拦截失败,导弹击中了美军导致28人丧生。最后调查发现是因为导弹系统采用的为24位位模式,无法精确的表示0.1秒,最终导致误差达到了0.3443秒。
那么现在你知道了精度的重要性,我们来体验一下吧。这里有n个分数,
Input
第一行输入一个整数
Output
输出
代码
代码:
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<stdio.h>
#include<cmath>
using namespace std;
int a[100],b[100],count;
int main()
{
int n;
cin>>n;
for(int i = 0;i < n ;i++)
{
cin>>a[i]>>b[i];
}
for(int i = 0;i < n - 1;i++)
{
count = 1;
int t1,t2;
t1 = a[i+1]*a[i];
t2 = b[i + 1]*b[i];
if(t2 == 0)
{
break;
}
else
{
if((t1 < 0&&t2 > 0) || (t1 > 0&&t2 < 0))
{
t1 = -t1;
cout<<"-";
}
cout<<t1/t2<<".";
int a[100],b[100],count;
int main()
{
int n;
cin>>n;
for(int i = 0;i < n ;i++)
{
cin>>a[i]>>b[i];
}
for(int i = 0;i < n - 1;i++)
{
count = 1;
int t1,t2;
t1 = a[i+1]*a[i];
t2 = b[i + 1]*b[i];
if(t2 == 0)
{
break;
}
else
{
if((t1 < 0&&t2 > 0) || (t1 > 0&&t2 < 0))
{
t1 = -t1;
cout<<"-";
}
cout<<t1/t2<<".";
while(count<=20)
{
t1 = t1 % t2 *10;
cout<<t1/t2;
count++;
}
cout<<endl;
}
{
t1 = t1 % t2 *10;
cout<<t1/t2;
count++;
}
cout<<endl;
}
}
return 0;
}
return 0;
}
阅读全文
0 0
- 20171202做的题
- 20171202做的题
- 可做的题
- 正在做的题
- 做题的感悟
- 做应该做的
- 我的做题笔记
- 入门必做的题
- 开始做poj的题
- 自己做了的题
- 自己做的笔试题
- leetcode的做题感悟
- leetcode 不会做的题
- 一些做过的题
- 做了一天的题
- 母函数做的题
- 做题碰到的知识点
- 做你想做的事
- PAT
- 【C语言】编写代码实现:求一个整数在内存中的二进制位中1的个数
- 华为LiteOS真相 噱头大于实际意义
- poj3253——Fence Repair
- C6748_PWM_ECAP
- 20171202做的题
- 017 大数定律(车比学夫、辛钦)及中心极限定理
- 分布式部署ResourceManager启动后马上关闭的问题
- Redundant Paths POJ
- LeetCode.322 Coin Change
- activiti java服务任务serviceTask的用法
- 【Scikit-Learn 中文文档】21 聚类
- android事件分发机制
- 【《计算机网络(第七版)》学习笔记】三、 数据链路层