Thursday
April 24, 2014

Homework Help: programming

Posted by Ryan on Saturday, October 24, 2009 at 2:09am.

I really need help in this it makes me confuse.I should make a program to find a pattern...so can somebody help me...
Write a function to recognize an pattern within another array. Your function should have the following prototype.


const int *find_pattern_in_int_array(const int *pattern, const int *array);


There are two parameters. The first one is pattern, which is an int pointer that points to the starting address of the pattern. The pattern ends with an int 0. The second parameter is the int array within which you need to locate the pattern. The array also ends with an int 0. If the pattern can be found in array, return the start address of last one within array. Otherwise you just return NULL. Note that you cannot access out of the array bound so you need to pay attention to the length of the pattern and the array, since the length of the array is not necessarily smaller than the length of the pattern.


You only need to write the function. The grading system will use various main programs to test the correctness of you function.
Please submit the function with #include<stdio.h>. DO NOT submit code with int main().


Sample Input/Output 1
Let's suppose you have pattern pointing to {8, 7, 0} and array pointing to {1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}.
In this case, you should return a pointer pointing to the second 8.


Sample Input/Output 2
pattern : {1, 2, 1, 0}
array : {1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}.
In this case, you should return NULL.

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

Programming Logic - I need to create a program that has (at least) two variables...
Programming Logic - I need to create a program that has (at least) two variables...
Math - Help, I can't find the pattern rule for this sequence(eg. -6,-3,2,9,18 ...
c programming - Plz give me some idea that how can i do this program. Write a ...
c programming - Write a program that uses a 20x20 board, initialised to a given ...
computer programming - Write a program that uses a 20x20 board, initialised to a...
computer programming - Write a program that uses a 20x20 board, initialised to a...
PROGRAMMING - PLS, I NEED TO BE GUIDED ON HOW TO WRITE A SIMPLE PROGRAM IN BASIC...
Algebra - Which of the following methods can be used to construct a pattern of ...
Algebra 2 - Which of the following methods can be used to construct a pattern of...

Search
Members