今天编程遇到一个新的报错,麻烦各位看看是什么意思,怎么解决,谢谢!
#include <iostream>#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
double a, b, c, area, cosA, cosB, cosC, pi = 3.14159;
cin>>a>>b>>c;
if(a + b > c && a + c > b && b + c > a)
{
cosA = (b * b + c * c - a * a) / (2 * b * c);
area = b * c * sqrt(1 - cosA * cosA) / 2;
cout<<"area = "<<setiosflags(::fixed)<<setprecision(4)<<area<<endl;
}
else cout<<"这三条边不能构成三角形。"<<endl;
return 0;
}
//C:\Users\Administrator\Desktop\c++\Cpp2.cpp(14) : error C2039: 'fixed' : is not a member of '`global namespace''
C:\Users\Administrator\Desktop\c++\Cpp2.cpp(14) : error C2664: 'setiosflags' : cannot convert parameter 1 from 'class std::ios_base &(__cdecl *)(class std::ios_base &)' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
执行 cl.exe 时出错.
cout<<"area = "<<setiosflags(::fixed)<<setprecision(4)<<area<<endl;这句里面的setiosflags(::fixed)
改成这样setiosflags(ios::fixed) 期待大侠们指导 machimilk 发表于 2014-2-25 23:28 static/image/common/back.gif
cout
啊,太粗心了,谢谢,这回记住了:hug:
页:
[1]