Results 1 to 6 of 6

Thread: Implement the find_end() in C++

  1. #1
    Join Date
    Dec 2009
    Posts
    28

    Implement the find_end() in C++

    Hello, I am the student of the Bsc-IT. I had learned the C++ language in first year of Bsc-IT. I can know about the functions in C++ language. I have to submit the assignment on the find_end() function. So, I would like to know about the find_end() function. I would also like to know how can I Implement the find_end() function in C++ language. If there is anyone who can have the solution on the find_end() functions then reply me!!!
    Last edited by Garrett; 15-02-2010 at 07:17 PM.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Implement the find_end() in C++

    PROGRAM :
    Code:
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    bool myfunction (int p, int q) 
    {
      return (p==q);
    }
    int main ()
     {
      int mint[] = {1,2,3,4,5,1,2,3,4,5};
      vector<int> mvctr (mint,mint+10);
      vector<int>::iterator t;
      int mtch1[] = {1,2,3};
      t = find_end (mvctr.begin(), mvctr.end(), mtch1, mtch1+3);
      if (t!=mvctr.end())
        cout << "match1 last found at position " << int(t-mvctr.begin()) << endl;
      int mtch2[] = {4,5,1};
      t = find_end (mvctr.begin(), mvctr.end(), mtch2, mtch2+3, mfnctn);
      if (t!=mvctr.end())
        cout << "match2 last found at position " << int(t-mvctr.begin()) << endl;
      return 0;
    }
    Output :
    Code:
    Match found at position 5
    Match found at position 3

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    The find_end() in C++

    The find_end() function can be used to find last sub sequence in a given range. The following can be the general syntax of the find_end() function in the C++ language :
    Code:
    template <class FrwrdItrtr1, class FrwrdItrtr2>
       FrwrdItrtr1 find_end ( FrwrdItrtr1 fst1, FrwrdItrtr1 lst1,
                                   FrwrdItrtr2 fst2, FrwrdItrtr2 lst2 );

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    The find_end()

    I suggest you to go through very carefully to the following code lines that can demonstrates you the implementation of the find_end() function in the C++ language :
    Code:
    #include <algorithm>  
    #include <functional> 
    #include <iostream>   
    #include <list>        
    int main()
    {
      char* t = "exec.exe";
      char* sufx = "exe";
      const int M = strlen(t);
      const int Nsuf = strlen(sufx);
      char* locat = find_end(t, t + M,
                                sufx, sufx + Nsuf);
      if (locat != t + M) 
    {
        cout << "Found a match for " << sufx << " within " << t << endl;
        cout << t << endl;
        int j;
        for (j = 0; j < (locat - t); ++j)
          cout << ' ';
        for (j = 0; j < Nsuf; ++j)
          cout << '^';
        cout << endl;
      }
      else
        cout << "No match for " << sufx << " within " << t << endl;
    }

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: Implement the find_end() in C++

    Hi, How's your Day!!! In a given sequence, [start1,finish1) the last occurrence of a sub-sequence that can be indicated by the [start2, finish2), can be find by using the function find_end(). If no match can be found by an iterator that can be pointing to the first element of the sub-sequence that can be found or finish1 can be returned by the find_end() function algorithm in C++ language.

  6. #6
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Implement the find_end() in C++

    The following can be the parameters of the find_end() function in the C++ language :
    1. fst2, lst2 : These parameters can be used for to searched Forward iterators to the final and starting positions of the sequence that can be searched for. The range used can be [fst2,lst2).
    2. fst1, lst1 : These parameters can be used for to searched Forward iterators to the final and starting positions of the sequence that can be searched. The range used can be [fst1,lst1).

Similar Threads

  1. How to implement sum() faster in c#?
    By Luis-Fernando in forum Software Development
    Replies: 4
    Last Post: 27-02-2010, 09:25 PM
  2. Implement the copy_backward() in C++
    By Agustíne in forum Software Development
    Replies: 5
    Last Post: 16-02-2010, 09:46 PM
  3. Implement the equal_range() in C++
    By Garrick in forum Software Development
    Replies: 5
    Last Post: 15-02-2010, 07:09 PM
  4. How to implement IP Sec
    By Enriquee in forum Technology & Internet
    Replies: 5
    Last Post: 12-01-2010, 06:28 AM
  5. Want to implement differentiation in C++
    By ADEN in forum Software Development
    Replies: 1
    Last Post: 25-10-2008, 06:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,474,004.42305 seconds with 16 queries