第十四周程序阅读例二
2015-06-10 08:34
232 查看
#include <iostream> using namespace std; int main() { int a=21; cout.setf(ios::showbase); cout<<"dec:"<<a<<endl; cout.unsetf(ios::dec); cout.setf(ios::hex); cout<<"hex:"<<a<<endl; cout.unsetf(ios::hex); cout.setf(ios::oct); cout<<"oct:"<<a<<endl; char *pt="China"; cout.width(10); cout<<pt<<endl; cout.width(10); cout.fill('*'); cout<<pt<<endl; double pi=22.0/7.0; cout.setf(ios::scientific); cout<<"pi="; cout.width(14); cout<<pi<<endl; cout.unsetf(ios::scientific); cout.setf(ios::fixed); cout.width(12); cout.setf(ios::showpos); cout.setf(ios::internal); cout.precision(6); cout<<pi<<endl; return 0; }
运行结果:
学习心得:
运用到了,设置输出格式状态setf()和中指已设置的输出格式状态unsetf()
相关文章推荐
- 第十三周项目二 形状类族中的纯虚函数
- 应用环境下的TIME_WAIT和CLOSE_WAIT处理
- linux驱动增加work工作队列和获取唤醒锁操作
- Workspace in use or cannot be created, choose a different one.
- 139 金正國 思齋 聽辨不詳 (金安國 弟)
- User survey(用户调研)
- 项目一
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(47)-工作流设计-补充
- Qt4升级Qt5注意问题
- js选下拉框 提交 (触发事件)
- 第14周项目1 - 小玩文件(2)
- 第14周程序阅读 例3
- 第十三周项目二 几何族类的纯虚函数
- 第14周项目1-小玩文件(2)
- 【游玩】待参观列表
- 第十四周项目1--小玩文件(2)
- 第十四周阅读程序cerr流对象
- FragmentPagerAdapter与FragmentStatePagerAdapter区别
- 配置管理系统和整体的变化对系统有什么区别和联系
- eclipse下创建Maven项目