#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;
#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