编程第五十五天

c++ algorithm头文件中find算法

  1. #include <iostream>  
  2. #include <algorithm>  
  3.   
  4. using namespace std;  
  5.   
  6. void printElem(int& elem)  
  7. {  
  8.   cout << elem << endl;  
  9. }  
  10.   
  11.   
  12. int main()  
  13. {  
  14.     int ia[]={0,1,2,3,4,5,6};  
  15.       
  16.     int *ifind(ia,ia+7,9);//在整个数组中查找元素 9   
  17.     int *jfind(ia,ia+7,3);//在整个数组中查找元素 3  
  18.     int *end=ia+7;//数组最后位置   
  19.     if(i == end)   
  20.        cout<<"没有找到元素 9"<<endl;  
  21.     else   
  22.        cout<<"找到元素9"<<endl;  
  23.          
  24.     if(j == end)   
  25.        cout<<"没有找到元素 3"<<endl;  
  26.     else   
  27.        cout<<"找到元素"<<*j<<endl;  
  28.     return 0;  
  29. }  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值