您的位置:首页 > 其它

第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就用空格在前面补全,这样前面就有空格了,还是跟大家一起学习有效率啊。


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: