十三周——输入输出流——阅读
2015-06-07 14:36
441 查看
问题及代码:
运行结果:
心得体会:
键代码注释
/* *Copyright (c) 2014,烟台大学计算机学院 *All rights reserved. *文件名称:lily.cpp *作者:李莉 *完成日期:2015年6月3日 *版本号:v1.0 *问题描述:控制输出的格式 程序输入:输入若干正数 程序输出:运行结果 */ #include <iostream> using namespace std; int main() { int a=21; cout.setf(ios::showbase);//设置技术符号 cout<<"dec:"<<a<<endl;//设置以10进制输出 cout.unsetf(ios::dec);//终止十进制的输出 cout.setf(ios::hex);//设置以十六进制的输出状态 cout<<"hex:"<<a<<endl;//以十六进制输出a cout.unsetf(ios::hex);//终止以十六进制的输出 cout.setf(ios::oct);//设置八进制的输出状态 cout<<"oct:"<<a<<endl;//八进制输出 char *pt="China"; cout.width(10);//设置输出的字段宽度是10位 cout<<pt<<endl;//输出字段宽度为10的字符串 cout.width(10);//设置字段宽度为10 cout.fill('*');//空白处以*填充 cout<<pt<<endl; double pi=22.0/7.0; cout.setf(ios::scientific);//用指定的科学计数法输出 cout<<"pi="; cout.width(14);//设置字段宽度为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; }
运行结果:
心得体会:
键代码注释
相关文章推荐
- 好久没写博客了
- 比较ASCII码时出错
- mysql 中文乱码
- 屏幕适配
- opencv里调用摄像头和捕捉图像帧的方案
- 错误:类型 'System.Object' 未定义或者不能引入项目
- 框架模式MVP在Android中的使用
- 12款很棒的浏览器兼容性测试工具推荐
- 机器学习 鲁棒的基于高斯概率密度的异常点检测(novelty detection) ellipticalenvelope算法
- 在启动php时,无法启动此程序,因为计算机中丢失MSVCR110.dll的解决方法
- 第六章 数据存储
- 百度地图 Android开发
- 如何有效防范SQL注入
- git工作流
- 网站优化:测试网站速度的8款免费工具推荐
- 【C++】String类中的运算符重载
- 【leetcode】 Balanced Binary Tree
- Java 爬虫
- 对编程语言的认识
- 初学后台框架总结篇一——学习过程