lt05.cpp

来自「一、教学目的: 能理解C++中运算符重载的需要性」· C++ 代码 · 共 18 行

CPP
18
字号
#include<iostream.h>
void fn(float interest,float amount)
{
	cout<<"RMB amount=";
	cout.precision(2);//置有效位数为2位
    cout<<amount;
	cout<<"\nthe interest=";
	cout.precision(4);//置有效位数为4位
	cout<<interest<<endl;
}
void main()
{
	float f1=29.41560067;
	float f2=12.567188;
	fn(f1,f2);
}
/*precision()为cout 对象的成员函数,在要求输出一定精度的数据之前,先调用
这个精度设置为成员函数*/

⌨️ 快捷键说明

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