| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 8666 人关注过本帖
标题:[求助]请教关于cout.setf(ios::fixed)这类的用法等问题 在线等
取消只看楼主 加入收藏
chlstc
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-1-8
收藏
 问题点数:0 回复次数:1 
[求助]请教关于cout.setf(ios::fixed)这类的用法等问题 在线等

请看这段代码,回答问题哦
#include<iostream.h>
#include<math.h>
void main()
{
const double pi=3.1415926;
const int interval=5;
cout<<" 角度x 正弦sin(x)";
cout<<" 余弦cos(x) 正切tan(x)";
float arc;
cout.setf(ios::fixed);
cout.precision(4);
for (int angle=0;angle<=90;angle+=interval)
{
arc=pi*angle/180;
cout<<endl;
cout.width(10);
cout<<angle;
cout.width(16);
cout<<sin(arc);
cout.width(16);
cout<<cos(arc);
cout.width(16);
if(angle==90||angle==-90)
cout<<"-";
else
cout<<tan(arc);
}


cout<<endl;
}

上面代码中cout.setf(ios::fixed); 和cout.precision;这两句还有cout.width();我不是很明白他们的用法和功能还有他们的作用域什么的,希望能帮小弟解释一下,越清楚越好哦,谢谢喽

[此贴子已经被作者于2007-6-25 16:07:21编辑过]

搜索更多相关主题的帖子: ios cout fixed setf 用法 
2007-06-25 16:06
chlstc
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-1-8
收藏
得分:0 

好像懂点了 继续看


我爱这个世界 简简单单 加QQ604804955吧
2007-06-25 17:01
快速回复:[求助]请教关于cout.setf(ios::fixed)这类的用法等问题 在线等
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017770 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved