⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 io20_9.06.c

📁 C++ PRIME书中的原代码,看本书时可以学习的例子.
💻 C
字号:
// #include <iostream>
// #include <iomanip>
// #include <cmath>

#include <iostream.h>
#include <iomanip.h>
#include <math.h>

/**
 ** note: must include the C standard math library
 **       unix: CC io20_9.06.c -lm
 **
 Precision: 6
 1.41421

 Precision: 12
 1.41421356237

 Precision: 3
 1.41
 **
 **/

int main()
{
	cout << "Precision: "
             << cout.precision() << '\n'
             << sqrt(2.0) << '\n';

        cout.precision(12);

	cout << "\nPrecision: "
	     << cout.precision() << '\n'
             << sqrt(2.0) << '\n';

	cout << "\nPrecision: "  << setprecision(3)
	     << cout.precision() << '\n'
	     << sqrt(2.0) << endl;

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -