cout.setf(ios_base::fixed,ios_base::floatfield);
#include<iostream>intmain(){usingnamespacestd;floathats,heads;cout.setf(ios_base::fix...
#include<iostream>
int main()
{
using namespace std;
float hats,heads;
cout.setf(ios_base::fixed,ios_base::floatfield);
cout<<"Enter a number:";
cin>>hats;
cout<<"Enter another number:";
cin>>heads;
cout<<"hats="<<hats<<"; heads="<<heads<<endl;
return 0;
}
程序输出是:
Enter a number:33.3
Enter another number:55.5
hats=33.299999
heads=55.000000
这是什么意思啊,对于cout.setf(ios_base::fixed,ios_base::floatfield);我不明白啊 展开
int main()
{
using namespace std;
float hats,heads;
cout.setf(ios_base::fixed,ios_base::floatfield);
cout<<"Enter a number:";
cin>>hats;
cout<<"Enter another number:";
cin>>heads;
cout<<"hats="<<hats<<"; heads="<<heads<<endl;
return 0;
}
程序输出是:
Enter a number:33.3
Enter another number:55.5
hats=33.299999
heads=55.000000
这是什么意思啊,对于cout.setf(ios_base::fixed,ios_base::floatfield);我不明白啊 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询