📄 example1-7.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>例1-7</title>
</head>
<body>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">#include <iostream.h><br>
#include <iomanip.h><br>
void main( )<br>
{<br>
double x=20.0/7, y=18.0/6;<br>
cout<<x<<endl;<br>
cout<<setiosflags(ios::scientific)<<x<<endl;<br>
cout<<setprecision(18)<<x<<endl;<br>
cout<<setiosflags(ios::fixed)<<x<<endl;<br>
cout<<setprecision(0)<<x<<endl;<br>
cout<<setprecision(6)<<y<<endl;<br>
cout<<setiosflags(ios::showpoint)<<y<<endl;<br>
}</font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font FACE="??ì?,SimSun" LANG="ZH-CN" size="2">程序输出结果是:</font></p>
<blockquote>
<blockquote>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">2.85714
<font FACE="??ì?,SimSun" LANG="ZH-CN">(默认</font>6<font FACE="??ì?,SimSun" LANG="ZH-CN">位</font>,<font FACE="??ì?,SimSun" LANG="ZH-CN">含小数点)</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">2.857143e+000
<font FACE="??ì?,SimSun" LANG="ZH-CN">(默认</font>6<font FACE="??ì?,SimSun" LANG="ZH-CN">位</font>,<font FACE="??ì?,SimSun" LANG="ZH-CN">不含小数点)</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">2.857142857142857e+000
<font FACE="??ì?,SimSun" LANG="ZH-CN">(</font>double<font FACE="??ì?,SimSun" LANG="ZH-CN">型最多</font>15<font FACE="??ì?,SimSun" LANG="ZH-CN">位)</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">2.85714285714286
<font FACE="??ì?,SimSun" LANG="ZH-CN">(</font>double<font FACE="??ì?,SimSun" LANG="ZH-CN">型最多</font>15<font FACE="??ì?,SimSun" LANG="ZH-CN">位,含小数点)</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">3
<font FACE="??ì?,SimSun" LANG="ZH-CN">(无小数位)</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">3
<font FACE="??ì?,SimSun" LANG="ZH-CN">(默认</font>0<font FACE="??ì?,SimSun" LANG="ZH-CN">不输出)</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">3.00000
<font FACE="??ì?,SimSun" LANG="ZH-CN">(强制输出</font>0<font FACE="??ì?,SimSun" LANG="ZH-CN">)</font></font></p>
</blockquote>
</blockquote>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font FACE="??ì?,SimSun" LANG="ZH-CN">若</font>double<font FACE="??ì?,SimSun" LANG="ZH-CN">改为</font>float<font FACE="??ì?,SimSun" LANG="ZH-CN">则程序输出结果是:</font></font></p>
<blockquote>
<blockquote>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">2.85714</font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">2.857143e+000</font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">2.857143e+000</font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">2.85714</font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">3</font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">3</font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">3.00000</font></p>
</blockquote>
</blockquote>
<p> </p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -