answer:
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 1 楼,分 1 页, 当前显示第 1 页 : 本帖树形列表 : 刷新 : 返回上一页
<<始页  [1]  末页>>
作者:simon (等级:10 - 炉火纯青,发帖:6859) 发表:2003-03-04 11:31:09  楼主  关注此帖
请问c++ cout 格式 的问题在c++里 如果 想cout 一个小数,怎么规定他的小数位数呢? eg: num = 3.6 cout (more...)
answer:
#include <iostream.h>
#include <iomanip.h>

int main()
{
double num = 3.6;
cout << setiosflags(ios::fixed | ios::showpoint);
cout << setprecision(2);
cout << num << endl;
}

/*
refer to any iomanip formatting document for c++ io formatting
*/

You may say I'm a dreamer
but I'm not the only one...
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
论坛导航 -> 华新鲜事 -> 求学狮城 | 返回上一页 | 本主题共有 1 篇文章,分 1 页, 当前显示第 1 页 | 回到顶部
<<始页  [1]  末页>>

请登录后回复:帐号   密码