第15周范型程序设计
2016-06-24 12:20
232 查看
/* *烟台大学计算机学院 *文件名称:xiangmu1.cpp *作者:李亚辉 *完成日期:2016年6月24日 *版本号:vc++6.0 * *问题描述: *输入描述: *程序输出:*/ #include <iostream> #include <vector> #include <algorithm> #include <functional> using namespace std; void show(double); int main() { double a1[5]={2,4,8,10,16}; double a2[5]={1,3,5,7,9}; cout.setf(ios_base::fixed); cout.precision(1); cout<<"a1:"<<endl; for_each(a1,a1+5,show); cout<<"a2:"<<endl; for_each(a2,a2+5,show); return 0; } void show(double v) { cout.width(6); cout<<v<<" "<<endl; } /*学习心得:一直不理解cout.width(6)什么意思,问了别人才知道,意思是输出宽度是6,如果实际内容不足6就用空格在前面补全,这样前面就有空格了,还是跟大家一起学习有效率啊。
相关文章推荐
- Linux 下C++编写
- Java基础之HashSet
- 何时用new?
- 关于 overridePendingTransition()使用
- React Native控件学习之ProgressBarAndroid讲解
- 安装oracle即时客户端
- Thinking in Java 笔记初衷
- TabHost,标签页的使用
- Hbuilder中百度地图插件的使用
- String.replaceAll()
- NYOJ 108 士兵杀敌(一)
- 用JSON-server模拟REST API(一) 安装运行
- I.MX6 U-boot imxotp MAC address 写入
- 设置动画
- ReactiveCocoa进阶
- this的面面观
- 暑期集训盲打首秀
- 第14周项目三—数组类模板
- Fatal error: Call-time pass-by-reference has been removed
- 求一个二维数组中每列的最小值