Line: 1 to 1  

 
Changed:  
< <  Due: Oct 17, 11:55pm  
> >  Due: March 22, 11:55pm  
Changed:  
< <  Moodle Link  
> >  Moodle Link  
Instructions

Line: 1 to 1  

 
Changed:  
< <  Due: March 21, 11:55pm  
> >  Due: Oct 17, 11:55pm  
Changed:  
< <  Moodle Link  
> >  Moodle Link  
Instructions

Line: 1 to 1  

 
Changed:  
< <  Due: Oct 18, 11:55pm  
> >  Due: March 21, 11:55pm  
Changed:  
< <  Moodle Link  
> >  Moodle Link  
Instructions

Line: 1 to 1  

 
Line: 91 to 92  
%ENDCODE%  
Changed:  
< <  Turn in:  
> >  Turn in:  
1. A search in array "3 6 6 6 4 7 8 8 4 6 2 4 10 4 8 6 6 4 2 6 6 6 4 7 8 6 5 6 4 6 4 2 6 5 6 5 6 5 5 1 2 1 3 6 4 7 8 6 8 6 6 4 2" 
Line: 1 to 1  

 
Line: 78 to 78  
// Postcondition: the n integers in a[] are displayed separated by spaces.
bool checkMatch(int a[], int as, int ao, int p[], int ps);  
Changed:  
< <  //Checks to see if the pattern p[] matches in a[] at the location ao  
> >  // Check to see if the pattern p[] matches in a[] at the location ao  
// Precondition: a[] has n integers, p[] has ps integers, ao is an index in A[].  
Changed:  
< <  // Postcondition: return a[ao] = p[0] && a[ao+1] = p[1] && .. && a[ao+ps1] == p[ps1]  
> >  // Postcontition: return false if ps is less then asao (pattern is longer then elemts left in a[]
// Postcontition: return true if the ints in p[] match the ints in a[] starting from ao, else false.
// Postcondition: (formally) return ps <= asao && a[ao] = p[0] && a[ao+1] = p[1] && .. && a[ao+ps1] == p[ps1]  
int countMatches(int a[], int as, int p[], int ps); // Precondition: a[] has as integers, p[] has ps integers  
Line: 88 to 91  
%ENDCODE%  
Changed:  
< <  Turn in:  
> >  Turn in:  
1. A search in array "3 6 6 6 4 7 8 8 4 6 2 4 10 4 8 6 6 4 2 6 6 6 4 7 8 6 5 6 4 6 4 2 6 5 6 5 6 5 5 1 2 1 3 6 4 7 8 6 8 6 6 4 2" 
Line: 1 to 1  

 
Line: 12 to 12  
Grading Table
 
Changed:  
< < 
 
> > 
 
 
Changed:  
< < 
 
> > 
 
Problem 
Line: 1 to 1  

 
Changed:  
< <  Moodle Link  
> >  Moodle Link  
Instructions
 
Line: 76 to 75  
// Precondition: a[] is an array of n integers. // Postcondition: the n integers in a[] are displayed separated by spaces.  
Changed:  
< <  int countMatches(int a[], int n, int p[], int ps); // Precondition: a[] has n integers, p[] has ps integers  
> >  bool checkMatch(int a[], int as, int ao, int p[], int ps);
//Checks to see if the pattern p[] matches in a[] at the location ao
// Precondition: a[] has n integers, p[] has ps integers, ao is an index in A[].
// Postcondition: return a[ao] = p[0] && a[ao+1] = p[1] && .. && a[ao+ps1] == p[ps1]
int countMatches(int a[], int as, int p[], int ps); // Precondition: a[] has as integers, p[] has ps integers  
// Postcondition: The number of occurrences of the pattern in p[] in a[] is returned
%ENDCODE% 
Line: 1 to 1  

 
Changed:  
< <  Due: Oct 13, 11:55pm  
> >  Due: Oct 18, 11:55pm  
Instructions  
Line: 97 to 99  
 
Changed:  
< < 
 
> > 
 

Line: 1 to 1  

 
Changed:  
< <  Lab 5  
> > 
 
Due: Oct 13, 11:55pm  
Added:  
> >  
Instructions
 
Line: 95 to 97  
 
Added:  
> > 

Line: 1 to 1  

Lab 5Due: Oct 13, 11:55pm  
Line: 6 to 6  
 
Added:  
> >  Grading Table
 
Problem  
Changed:  
< <  Pattern Matching: Write a program that looks for a pattern of integers in an array of integers. The program first asks the user to input up to 100 numbers greater than or equal to zero. The user terminates the input with a negative number or sentinal. The program automatically moves to the next step after 100 numbers has been entered.  
> >  Pattern Matching: Write a program that looks for a pattern of integers in an array of integers. The program first asks the user to input up to 100 numbers greater than or equal to zero. The user terminates the input with a negative number or sentinel. The program automatically moves to the next step after 100 numbers has been entered.  
The program then enters a loop, and asks the users to enter a sequence of up to 10 numbers. As before, they enter numbers until either a negative number is entered, or they have entered 10 numbers. This array will be called the pattern.  
Line: 19 to 26  
If the user enters a negative number when as the first number in a pattern, the pattern is empty, and the program terminates.  
Added:  
> >  If the number list or pattern is longer than 100 or 10, respectively, ignore the extra, using the first 100 or 10.  
If the user enters a pattern that is longer then the search array, give the user an error.
Example:  
Changed:  
< <  Enter up to 100 integers: 1 4 3 6 8 5 12 5 6 8 5 2 9 3 1 4 3 6 6 8 5 1 Enter a pattern: 2 1 Matches:1 Pattern 2 Enter a pattern: 6 8 5 1 Matches:3 Pattern 6 8 5  
> >  Enter up to 100 integers (1 to end): 1 4 3 6 8 5 12 5 6 8 5 2 9 3 1 4 3 6 6 8 5 1  
Changed:  
< <  Enter a pattern: 1 Good bye!  
> >  Enter a pattern (Up to 10, 1 to end): 6 1
Array: 1 4 3 6 8 5 12 5 6 8 5 2 9 3 1 4 3 6 6 8 5
Pattern: 6
Matches: 4
Enter 'C' to continue:C
Enter a pattern (Up to 10, 1 to end): 6 8 5 1 Array: 1 4 3 6 8 5 12 5 6 8 5 2 9 3 1 4 3 6 6 8 5 Pattern: 6 8 5 Matches: 3 Enter 'C' to continue:C Enter a pattern (Up to 10, 1 to end): 6 5 2 1 Array: 1 4 3 6 8 5 12 5 6 8 5 2 9 3 1 4 3 6 6 8 5 Pattern: 6 5 2 Matches: 0 Enter 'C' to continue:C Enter a pattern (Up to 10, 1 to end): 1 3 2 4 3 4 2 4 3 4 2 1 3 1 3 4 1 Array: 1 4 3 6 8 5 12 5 6 8 5 2 9 3 1 4 3 6 6 8 5 Pattern: 1 3 2 4 3 4 2 4 3 4 Matches: 0 Enter 'C' to continue: RUN FINISHED; exit value 0; real time: 1m 3s; user: 0ms; system: 0ms  
Added:  
> >  Solution Strategy
You should create the following functions as part of your solution:
< SyntaxHighlightingPlugin > void getArray(int a[], int max, int& count); // Precondition: a[] is a array, MAX is the size of a[]; // Postcondition: a[] contains up tp MAX numbers entered by user, and count is the number of number entered void displayArray(int a[], int n) ; // Precondition: a[] is an array of n integers. // Postcondition: the n integers in a[] are displayed separated by spaces. int countMatches(int a[], int n, int p[], int ps); // Precondition: a[] has n integers, p[] has ps integers // Postcondition: The number of occurrences of the pattern in p[] in a[] is returned < end SyntaxHighlightingPlugin >  
Turn in:  
Changed:  
< <  1. A search in array "3 6 4 7 8 4 6 2 4 10 4 8 6 5 4 6 4 6 8 6 5 6 4 2 7 9 6 5 6 5 6 5 5 1 2 1 3 6 4 7 8 6 8 6"  
> >  1. A search in array "3 6 6 6 4 7 8 8 4 6 2 4 10 4 8 6 6 4 2 6 6 6 4 7 8 6 5 6 4 6 4 2 6 5 6 5 6 5 5 1 2 1 3 6 4 7 8 6 8 6 6 4 2"  
Changed:  
< < 
 
> > 
 
 
Added:  
> > 

Line: 1 to 1  

Lab 5Due: Oct 13, 11:55pmInstructions  
Deleted:  
< < 
 
 
Changed:  
< <  Grading
Problem 1
Write a program that reads in a list of integers into an array with base type For example, for the following input Input the number of entries: 16 Enter the numbers: 12 3 12 4 1 1 12 1 1 1 2 3 4 2 3 12 the output should be
Hint  
> > 
 
Changed:  
< <  It is MUCH easier to count the number of occurances if you sort the numbers first, then do the counting.
Turn inA run with a 10 numbers, and a run 30 numbera
Problem 2  
> >  Problem  
Pattern Matching: Write a program that looks for a pattern of integers in an array of integers. The program first asks the user to input up to 100 numbers greater than or equal to zero. The user terminates the input with a negative number or sentinal. The program automatically moves to the next step after 100 numbers has been entered.  
Line: 69 to 35  
Good bye!  
Deleted:  
< <  </pre>  
Turn in:
1. A search in array "3 6 4 7 8 4 6 2 4 10 4 8 6 5 4 6 4 6 8 6 5 6 4 2 7 9 6 5 6 5 6 5 5 1 2 1 3 6 4 7 8 6 8 6" 
Line: 1 to 1  

Lab 5  
Changed:  
< <  Due: Oct 19, 11:55pm  
> >  Due: Oct 13, 11:55pm  
Instructions

Line: 1 to 1  

Lab 5  
Changed:  
< <  Due: Oct 17, 11:55pm  
> >  Due: Oct 19, 11:55pm  
Instructions

Line: 1 to 1  

Lab 5Due: Oct 17, 11:55pm  
Line: 14 to 14  
 
Changed:  
< <  Problems  
> >  Problem 1  
Changed:  
< <  1. Write a program that reads in a list of integers into an array with base type int . The program will require the user to input the numbers. You may assume that there are fewer than 50 entries in the array. If the user specifies more than 50, you should provide an error meaage, and ask them to reenter. The output is to be a twocolumn list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.  
> >  Write a program that reads in a list of integers into an array with base type int . The program will require the user to input the numbers. You may assume that there are fewer than 50 entries in the array. If the user specifies more than 50, you should provide an error meaage, and ask them to reenter. The output is to be a twocolumn list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.  
For example, for the following input  
Line: 35 to 35  
Hint  
Changed:  
< <  It is MUCH easier to make the number of occurances if you sort the numbers first, then do the counting.  
> >  It is MUCH easier to count the number of occurances if you sort the numbers first, then do the counting.
Turn in  
Changed:  
< <  Turn in: A run with a 10 numbers, and a run 30 numbera  
> >  A run with a 10 numbers, and a run 30 numbera  
 
Added:  
> >  Problem 2  
Changed:  
< <  2. Pattern Matching: Write a program that looks for a pattern of integers in an array of integers. The program first asks the user to input up to 100 numbers greater than or equal to zero. The user terminates the input with a negative number or sentinal. The program automatically moves to the next step after 100 numbers has been entered.  
> >  Pattern Matching: Write a program that looks for a pattern of integers in an array of integers. The program first asks the user to input up to 100 numbers greater than or equal to zero. The user terminates the input with a negative number or sentinal. The program automatically moves to the next step after 100 numbers has been entered.  
The program then enters a loop, and asks the users to enter a sequence of up to 10 numbers. As before, they enter numbers until either a negative number is entered, or they have entered 10 numbers. This array will be called the pattern. 
Line: 1 to 1  

Lab 5  
Changed:  
< <  Due: Oct 15, 11:55pm  
> >  Due: Oct 17, 11:55pm  
Instructions  
Added:  
> > 
 
Grading  
Line: 32 to 33  
 
Added:  
> >  HintIt is MUCH easier to make the number of occurances if you sort the numbers first, then do the counting.  
Turn in: A run with a 10 numbers, and a run 30 numbera 
Line: 1 to 1  

Lab 5  
Changed:  
< <  Due: Oct 6, 11:55pm  
> >  Due: Oct 15, 11:55pm  
Instructions

Line: 1 to 1  

Lab 5Due: Oct 6, 11:55pm  
Line: 15 to 15  
Problems  
Changed:  
< <  1. One problem we have encountered is using cin for numeric data. If we enter a nonnueric value when the system is expecting a numberic value, the cin object goes into an error state, and all further =cin='s are ignored.One solution to this problem was persented here: Link.
What we want to do is write a function that gets the next integer from The method we will employ
2. Write a program that reads in a list of integers into an array with base type  
> >  1. Write a program that reads in a list of integers into an array with base type int . The program will require the user to input the numbers. You may assume that there are fewer than 50 entries in the array. If the user specifies more than 50, you should provide an error meaage, and ask them to reenter. The output is to be a twocolumn list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.  
For example, for the following input  
Line: 38 to 32  
 
Added:  
> > 
Turn in: A run with a 10 numbers, and a run 30 numbera
2. Pattern Matching: Write a program that looks for a pattern of integers in an array of integers. The program first asks the user to input up to 100 numbers greater than or equal to zero. The user terminates the input with a negative number or sentinal. The program automatically moves to the next step after 100 numbers has been entered. The program then enters a loop, and asks the users to enter a sequence of up to 10 numbers. As before, they enter numbers until either a negative number is entered, or they have entered 10 numbers. This array will be called the pattern. The program then searches the larger array for a subsequence of numbers that matches the pattern. It will continue to search until it finds all instances of that pattern, counting the matches. (Note that for this exercise patterns cannot overlap, e.g. when you find a pattern, start searching for then next only AFTER the previous pattern. The program will then report the number of matching, and then ask for another pattern to be entered. If the user enters a negative number when as the first number in a pattern, the pattern is empty, and the program terminates. If the user enters a pattern that is longer then the search array, give the user an error. Example: Enter up to 100 integers: 1 4 3 6 8 5 12 5 6 8 5 2 9 3 1 4 3 6 6 8 5 1 Enter a pattern: 2 1 Matches:1 Pattern 2 Enter a pattern: 6 8 5 1 Matches:3 Pattern 6 8 5 Enter a pattern: 1 Good bye! </pre> Turn in: 1. A search in array "3 6 4 7 8 4 6 2 4 10 4 8 6 5 4 6 4 6 8 6 5 6 4 2 7 9 6 5 6 5 6 5 5 1 2 1 3 6 4 7 8 6 8 6"

Line: 1 to 1  

Lab 5Due: Oct 6, 11:55pm  
Line: 15 to 15  
Problems  
Changed:  
< <  1. Write a program that reads in a list of integers into an array with base type int . The program will require the user to input the numbers. You may assume that there are fewer than 50 entries in the array. If the user specifies more than 50, you should provide an error meaage, and ask them to reenter. The output is to be a twocolumn list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.  
> >  1. One problem we have encountered is using cin for numeric data. If we enter a nonnueric value when the system is expecting a numberic value, the cin object goes into an error state, and all further =cin='s are ignored.One solution to this problem was persented here: Link.
What we want to do is write a function that gets the next integer from The method we will employ
2. Write a program that reads in a list of integers into an array with base type  
For example, for the following input  
Changed:  
< <  Input the number of entries: 16  
> >  Input the number of entries: 16  
Enter the numbers: 12 3 12 4 1 1 12 1 1 1 2 3 4 2 3 12 
Line: 1 to 1  

Lab 5Due: Oct 6, 11:55pm  
Line: 15 to 15  
Problems  
Deleted:  
< <  1.  
\ No newline at end of file  
Added:  
> >  1. Write a program that reads in a list of integers into an array with base type int . The program will require the user to input the numbers. You may assume that there are fewer than 50 entries in the array. If the user specifies more than 50, you should provide an error meaage, and ask them to reenter. The output is to be a twocolumn list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.
For example, for the following input
Input the number of entries: 16 Enter the numbers: 12 3 12 4 1 1 12 1 1 1 2 3 4 2 3 12 the output should be

Line: 1 to 1  

Added:  
> > 
Lab 5Due: Oct 6, 11:55pmInstructions
Grading
Problems1. 