假定x=3.73486,编写程序,分别输出x保留一位,二位,三位小数的形式。

[复制链接]
查看11 | 回复1 | 2012-5-2 10:16:01 | 显示全部楼层 |阅读模式
#includevoid main(){double x=3.73486;printf("%.1lf %.2lf %.3lf\n",x,x,x);}#include #include void main() { double x=3.73486; cout<<setprecision(1)<< setiosflags(ios::fixed | ios::showpoint )<<x<<endl;
cout<<setprecision(2)<<x<<endl;
cout<<setprecision(3)<<x<<endl; ...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行