当前位置:网站首页>【码蹄集新手村 600 题】科学计数法的实现方式,输出指数形式
【码蹄集新手村 600 题】科学计数法的实现方式,输出指数形式
2022-07-17 18:23:00 【Sandm *】
题目链接:
解题思路:
科学计数法:
- 整数计数法:
(1)7.823E5=782300,这种表示方式就是:E代表10,E后面的数代表的是指数位,例如这里的5代表指数是10的5次方
(2)1234567 = 1.234567E+6,这种表示方式是:1.表示的是1.234567乘以后面的数,也就是后面的E+6表示的是10的6次方
- 小数计数法
(1)1.23456e+002 ,这个数的表示方式就是,e+002 表示10 的2次方,这里的数就是123.456。
(2)202 +0.00000E+00,这样的数就是表示为202加上后面有个精确到小数点后五位的数

在 printf 函数中使用格式控制符来输出指数形式的小数
在 C++ 我们可以用关键字 scientific 来实现指数形式的打印
只不过这俩种方式只能输出后俩位
而该题目要求输出后三位
所以我们可以自己编写一个求科学计数法的函数
参考代码:
#include<bits/stdc++.h>
using namespace std;
double a = 3.1415926,b = 12345678.123456789;
void solve (double a)
{
printf("%.6lf",a);
int i = 0;
while(a > 10)
{
a = a/10.0;//别忘了小数点
i++;
}
printf(" %.6lfe+",a);
cout << setw(3) << setfill('0') << i ;
return;
}
int main( )
{
solve(a);
cout << endl;
solve(b);
return 0;
}边栏推荐
- onvif协议相关:2.1.2 none方式获取截图url
- onvif协议相关:3.1.2 Digest方式获取token列表
- 【刷题记录】13. 罗马数字转整数
- Security measures for tcp/ip protocol vulnerabilities
- CMOS switch learning (I)
- Attachment handling of SAP Fiori
- onvif协议相关:4.1.1 WS-Username token方式获取WSUsernameTokenBean
- torch.utils.data.DataLoader说明
- JVM self study summary
- Codeforce:g. good key, bad key [greed]
猜你喜欢
[email protected] Cobalt iron bimetallic organic skeleton cox/mil-100 (FE) | [email protected]

onvif协议相关:4.1.2 WS-Username token方式获取token

Qt之使用QLisView实现QQ登录历史列表

Uio-66 | fe3o4/cu3 (BTC) 2 metal organic framework (MOF) nanocomposites supported on silver nanoparticles | nagdf4:yb, er upconversion nanoparticles @zif-8

JVM self study summary
![[Tencent blue whale] the seventh 7.24 operation and maintenance day holiday greetings ~ come and make a wish~](/img/60/ab96abd599230078b19abad0aecba2.png)
[Tencent blue whale] the seventh 7.24 operation and maintenance day holiday greetings ~ come and make a wish~

Forget about postman. Apifox is better

torch. utils. data. Dataloader description
![Codeforce:g. good key, bad key [greed]](/img/5e/e34e549c15e2e495d3a274ea8e6f82.png)
Codeforce:g. good key, bad key [greed]

Onvif protocol related: 2.1.1 get token in none mode
随机推荐
(PC+WAP)织梦模板服装礼服类网站
Panasonic A6 servo driver external absolute value grating ruler full closed loop parameter setting
torch. utils. data. Dataloader description
模板虚拟机环境准备
MySQL advanced (VI) introduction to four common uses of fuzzy query
Forget about postman. Apifox is better
STM32F1与STM32CubeIDE编程实例-MPU-6050 六轴(陀螺仪 + 加速度计)驱动
【码蹄集新手村 600 题】格式化的输入输出,使用 0 来代替补全的空格
忘掉Postman,Apifox更好用
onvif协议相关:2.1.2 none方式获取截图url
XML建模(简单易学)
如何优雅的升级 Flink Job?
Module 7 (Architecture Design of King glory mall)
Interviewer: is it acceptable to transfer to go?
Ossimport migration path
(pc+wap) dream weaving template clothing dress website
LeetCode 0565.数组嵌套:转换为图 + 原地修改の优化
健康防猝指南3:健康保健
[try to hack] ARP and ARP deception
Onvif protocol related: 2.1.2 get screenshot URL in none mode