c++中提示 'setprecision' was not declared in this scope什么意思
#include<iostream>usingnamespacestd;intmain(){inttime,money,howmoney;cin>>money>>time...
#include<iostream>
using namespace std;
int main()
{
int time,money,howmoney;
cin>>money>>time;
if(money<=2)
{
howmoney=6;
}
else if(money>2&&money<=10)
{
howmoney=money*1.8;
}
else
howmoney=money*(1.8*1.5);
if(time>0)
{
howmoney=howmoney+time/3*1;
}
cout<<fixed<<setprecision(4)<<howmoney<<"元";
return 0;
} 展开
using namespace std;
int main()
{
int time,money,howmoney;
cin>>money>>time;
if(money<=2)
{
howmoney=6;
}
else if(money>2&&money<=10)
{
howmoney=money*1.8;
}
else
howmoney=money*(1.8*1.5);
if(time>0)
{
howmoney=howmoney+time/3*1;
}
cout<<fixed<<setprecision(4)<<howmoney<<"元";
return 0;
} 展开
2个回答
展开全部
setprecision不是<iostream>头文件中所包括的内容,是<iomanip>头文件包含的,所以要在最前面加上一句话:#include <iomanip>
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int time,money,howmoney;
cin>>money>>time;
if(money<=2)
{
howmoney=6;
}
else if(money>2&&money<=10)
{
howmoney=money*1.8;
}
else
howmoney=money*(1.8*1.5);
if(time>0)
{
howmoney=howmoney+time/3*1;
}
cout<<fixed<<setprecision(4)<<howmoney<<"元";
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询