泛型算法之find

Xredman posted @ Jun 14, 2009 09:42:20 AM in 以前博文 , 1154 阅读

 

#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
using namespace std;

const int N = 10;

int main()
{
        int str[10], cc = 1;
        vector<int> ivec;
        list<int> ilist;
        ivec.clear();
        ilist.clear();

        for(int i = 0; i < N; i++)
        {
                str[i] = cc;
                ivec.push_back(cc + 10);
                ilist.push_back(cc + 20);
                cc++;
        }

        while(cin>>cc)
        {
                if(find(str, str + N, cc) != str + N)
                        cout<<"在数组中找到"<<endl;
               
                if(find(ivec.begin(), ivec.end(), cc) != ivec.end())
                        cout<<"在vector中找到"<<endl;

                if(find(ilist.begin(), ilist.end(), cc) != ilist.end())
                        cout<<"在list中找到"<<endl;
        }

        return 0;
}

 

 






  • 无匹配
  • 无匹配
CBSE 5th Class Book 说:
Sep 06, 2023 12:02:24 AM

CBSE Textbooks for 5th Class English, Hindi, Mathematics, Science, Social Science, and Sanskrit are available in this webpage. You will get the Download links of CBSE Class Textbooks 2024 Students 5th Class which CBSE 5th Class Book 2024 will help to prepare Final Examination Prepare of CBSE Board. Central Board Class Students your Textbooks online provide our website, Visit our web portal Download CBSE Class Books 2024 Pdf links.CBSE Class Textooks 2024 are Quite Important when we talk about the Central Exam as these 5th Class book are Prepared as per the Syllabus Prescribed for CBSE Exam. so the CBSE – NCERT Class Textooks 2024 can be Considered as the Complete Preparation Material for the Exam.

boardmodelpaper.com 说:
Jan 04, 2024 09:42:01 PM

Board Model Papers 2024 Download with Suggestions for 10th Class Textbooks 2024 Pdf Download and SSLC New Syllabus Sample Question Paper 2024 and different types of model papers boardmodelpaper.com and question papers for following the website and Arts, Science, Commerce Stream Subject Wise Solved Question Bank for Hindi & English Medium Students with Exam Pattern & Blueprint and subject Wise with 11th & 12th Question Bank 2024 for General & Vocational Course Languages & Subjects Important Question for the above link.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter