c++ 显示小数点后的0
#include "stdafx.h"#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout.setf(ios_base::fixed, ios_base::floatfield);
float num = 0.300;
cout << num << endl;
return 0;
}
一般情况下,不加cout.setf(ios_base::fixed, ios_base::floatfield);会显示0.3,当加了这个后,就显示0.300
文档来源:51CTO技术博客https://blog.51cto.com/u_10486491/3215412
页:
[1]