Dev-c++编译时提示[Error] 'std::precision' has not been declared

1997dz 2017-03-08 09:29:44
#include<iomanip>
#include<ios>
#include<iostream>
#include<string>

using std::cin; using std::setprecision;
using std::cout; using std::string;
using std::endl; using std::streamsize;
using std::precision;

int main()
{
cout<<"please enter your first name: ";
string name;
cin>>name;
cout<<"hello, "+name+"! "<<endl;

cout<<"please enter your midterm and final grades: ";
double midterm,final;
cin>>midterm>>final;

cout<<"enter your all homework grades: ";

int count = 0;
double sum = 0;
double x;

while(cin>>x)
{
++count;
sum+=x;
}

streamsize prec = cout.precision();
cout<<"your final grade is "<<setprecision(3)<<0.2*midterm+0.4*final+0.4*sum/count<<setprecision(prec)<<endl;

return 0;
}
//本人菜鸟一枚,以上代码来自教科书,却无法在dev-cpp5.9.2上正常运行,请问是为什么?还请各路大神指点一二,感激不尽。
//以下为编译提示的错误
//9 12 C:\Users\11204\Desktop\cpp\3.1例子.cpp [Error] 'std::precision' has not been declared
...全文
1183 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
flying_music 2017-03-08
  • 打赏
  • 举报
回复
把using std::precision;注释掉
ipqtjmqj 2017-03-08
  • 打赏
  • 举报
回复
你可能用了本假的教科书

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧