IDEA: Search And Replace

This is a discussion on IDEA: Search And Replace within the Contests Board forums, part of the Community Boards category; A program to search a file(s) for a specific piece of text, and replace it with something specified by the ...

  1. #1
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493

    IDEA: Search And Replace

    A program to search a file(s) for a specific piece of text, and replace it with something specified by the user. More configurable the better.

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    How about a function.. Not like the one you had last time.. But something like...

    (from some other site)
    You are given two strings (array of chars)- A and B. String A has N cells, and string B has M cells (3<=N,M<=250). You should write a function that will find the longest common sub-string that appears in both- A and B. Common sub-string, is a sequence of chars/ints that appears in the both strings, and from all such equal sub-strings, you should find the one which has greatest length.
    For example:
    A = 16121353f49ar44
    B = 6q6353f0
    True answer: 353f
    Another example:
    A = 1q12e13534a9
    B = 67n8f87
    True answer: 0 (there is no common sub-strings)

    Function prototype:
    char *find_substring(char A[], char B[], int N, int M);
    or:
    char *find_substring(char *A, char *B, int N, int M);

    Which one you will use, depends on you. We don't mind no matter which one you will use.

    Where:
    A is the first array of chars/ints.
    B is the second array of chars/ints.
    N is the size of A (the number of cells)
    M is the size of B (the number of cells)

    Your function should return the longest common substring. If there is not such one, then, it should return 0.

    Notice: In case there are two sub-strings with the same max length, return the last one

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. vector search and replace
    By rahulsk1947 in forum C++ Programming
    Replies: 6
    Last Post: 06-04-2009, 09:13 PM
  2. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  3. open file, search of word, replace word with another
    By Unregistered in forum C++ Programming
    Replies: 0
    Last Post: 06-05-2002, 01:16 PM
  4. string search and replace
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-22-2002, 01:50 AM
  5. Search and replace coding....
    By bishop_74 in forum C++ Programming
    Replies: 5
    Last Post: 12-05-2001, 02:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21