描述
Calculate a × b.
输入
The input will consist of a series of pairs of floating point numbers a and b,separated by a space, one pair of floating point numbers per line.
输出
For each pair of input floating point numbers a and b you should output the product of a and b in one line,and with one line of output for each line in input.
Output should be rounded to 3 digits after decimal point.
样例输入
1.1 1.1
1 0
1.234 5.678
样例输出
1.210
0.000
7.007
代码:
#include<iostream>
#include<iomanip>/*这个头文件是声明一些 “流操作符”的,
常用的有:
setw(int):设置显示宽度。
left//right:设置左右对齐。
setprecision(int):设置浮点数的精确度。*/
using namespace std;
int main()
{
double a, b;
while (cin >> a >> b)
{
cout<<fixed << setprecision(3)<< a * b<<endl;/*setprecision(3)是改为3精度,加了fixed意味着是固定点方式显示,
所以这里的精度指的是小数位。*/
}
return 0;
}