程序填空

  1. /* 
  2. *Copyright (c) 2015,烟台大学计算机学院 
  3. *All rights reserved. 
  4. *文件名称:text.cpp 
  5. *作者:李德彪
  6. *完成日期:2015年6月23日 
  7. *版本号:v1.0 
  8. * 
  9. *问题描述:程序填空 
  10. *输入描述: 无 
  11. *程序输出: 
  12. */  
  13. #include <iostream>  
  14. #include<vector>  
  15. #include<algorithm>  
  16. #include<functional>  
  17. using namespace std;  
  18. void Show(double );  
  19. int main()  
  20. {  
  21.     double arr1[5]={2,4,8,10,16};  
  22.     double arr2[5]={1,3,5,7,9};  
  23.     cout.setf(ios_base::fixed);  
  24.     cout.precision(1);  
  25.     cout<<"arr1:\t";  
  26.     for_each(arr1,arr1+5,Show);  
  27.     cout<<endl;  
  28.     cout<<"arr2:\t";  
  29.     for_each(arr2,arr2+5,Show);  
  30.     cout<<endl;  
  31.     vector<double >sum(5);  
  32.     transform(arr1,arr1+5,arr2,sum.begin(),plus<double>());  
  33.     cout<<"sum:\t";  
  34.     for_each(sum.begin(),sum.end(),Show);  
  35.     cout<<endl;  
  36.     vector<double>prod(5);  
  37.     transform(arr1,arr1+5,prod.begin(),bind1st(multiplies<double>(),2.5));  
  38.     cout<<"prod:\t";  
  39.     for_each(prod.begin(),prod.end(),Show);  
  40.     cout<<endl;  
  41.     return 0;  
  42. }  
  43. void Show(double v)  
  44. {  
  45.     cout.width(6);  
  46.     cout<<v<<' ';  
  47. }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值