Difference: Lab5 (1 vs. 21)

Revision 212018-03-01 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5 - Pattern Matching

Changed:
<
<

Due: Oct 17, 11:55pm

>
>

Due: March 22, 11:55pm

 
Changed:
<
<
Moodle Link
good-versus-bad-patterns.jpg
>
>
Moodle Link
good-versus-bad-patterns.jpg
 

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.

Revision 202017-09-22 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5 - Pattern Matching

Changed:
<
<

Due: March 21, 11:55pm

>
>

Due: Oct 17, 11:55pm

 
Changed:
<
<
Moodle Link
good-versus-bad-patterns.jpg
>
>
Moodle Link
good-versus-bad-patterns.jpg
 

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.

Revision 192017-03-21 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5 - Pattern Matching

Line: 80 to 80
  bool checkMatch(int a[], int as, int ao, int p[], int ps); // Check to see if the pattern p[] matches in a[] at the location ao
Changed:
<
<
// Precondition: a[] has n integers, p[] has ps integers, ao is an index in A[].
>
>
// Precondition: a[] has as integers, p[] has ps integers, ao is an index in A[].
 // Postcontition: return false if ps is less then as-ao (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 <= as-ao && a[ao] = p[0] && a[ao+1] = p[1] && .. && a[ao+ps-1] == p[ps-1]
Line: 105 to 105
 
  • Search for 8 9 10
  • Search for 1 2 3 4 5 6 7 8 9 10
Changed:
<
<
  • Search for 1 2 3 4 5 6 7 8 9 10 11
>
>
  • Search for 12
 
  • Search for 5 6 7

Solution

Revision 182017-01-17 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5 - Pattern Matching

Changed:
<
<

Due: Oct 18, 11:55pm

>
>

Due: March 21, 11:55pm

 
Changed:
<
<
Moodle Link
good-versus-bad-patterns.jpg
>
>
Moodle Link
good-versus-bad-patterns.jpg
 

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.

Revision 172016-10-20 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5 - Pattern Matching

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"

Revision 162016-10-20 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5 - Pattern Matching

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+ps-1] == p[ps-1]
>
>
// Postcontition: return false if ps is less then as-ao (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 <= as-ao && a[ao] = p[0] && a[ao+1] = p[1] && .. && a[ao+ps-1] == p[ps-1]
  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"

Revision 152016-10-19 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5 - Pattern Matching

Line: 12 to 12
 
  • You will need to use arrays

Grading Table

Requirement Grading Comments Points Score
Changed:
<
<
Good clean, easy to understand input and output operations (All sort code included)   10  
Program handles input error conditions appropriately   10  
Complete source code with good formatting and organization, variables names, and comments   10  
>
>
Easy to use user interface   10  
C++ code includes comments, with project information at top, pre and post conditions for each functions and other cmments as needed.   10  
The C++ code has good formatting, indentation, and organization.   10  
Good variable and function names, appropriate use of constants rather then literal numbers.   10  
 
Functions: Logic divided up into cohesive functions with a single purpose   20  
Changed:
<
<
Runs: Run examples from trials with correct output on required trial data   50  
>
>
Runs: Run examples from trials with correct output   40  
Total   100  
 

Problem

Revision 142016-10-19 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5 - Pattern Matching

Due: Oct 18, 11:55pm

Changed:
<
<
Moodle Link
good-versus-bad-patterns.jpg
>
>
Moodle Link
good-versus-bad-patterns.jpg
 

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
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+ps-1] == p[ps-1]

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%

Revision 132016-10-12 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5 - Pattern Matching

Changed:
<
<

Due: Oct 13, 11:55pm

>
>

Due: Oct 18, 11:55pm

Moodle Link

 
good-versus-bad-patterns.jpg

Instructions

Line: 97 to 99
 
  • Search for 5 6 7

Solution

Changed:
<
<
  • good-versus-bad-patterns.jpg:
>
>
  • good-versus-bad-patterns.jpg:
 
META FILEATTACHMENT attachment="good-versus-bad-patterns.jpg" attr="" comment="" date="1475260661" name="good-versus-bad-patterns.jpg" path="good-versus-bad-patterns.jpg" size="50982" user="JimSkon" version="1"

Revision 122016-09-30 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"
Changed:
<
<

Lab 5

>
>

Lab 5 - Pattern Matching

 

Due: Oct 13, 11:55pm

Added:
>
>
good-versus-bad-patterns.jpg

 

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
  • Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.
Line: 95 to 97
 
  • Search for 5 6 7

Solution

Added:
>
>
  • good-versus-bad-patterns.jpg:

META FILEATTACHMENT attachment="good-versus-bad-patterns.jpg" attr="" comment="" date="1475260661" name="good-versus-bad-patterns.jpg" path="good-versus-bad-patterns.jpg" size="50982" user="JimSkon" version="1"

Revision 112016-09-29 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5

Due: Oct 13, 11:55pm

Line: 6 to 6
 
  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
  • Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.
  • You will need to use arrays
Added:
>
>

Grading Table

Requirement Grading Comments Points Score
Good clean, easy to understand input and output operations (All sort code included)   10  
Program handles input error conditions appropriately   10  
Complete source code with good formatting and organization, variables names, and comments   10  
Functions: Logic divided up into cohesive functions with a single purpose   20  
Runs: Run examples from trials with correct output on required trial data   50  
 

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:
<
<
  • Search for 3
  • Search for 6 4 2
  • Search for 6 6 4 7 8
  • Search for 5 4 3 2 1
2. A search in array "1 2 3 4 5 6 7 8 9 10"
>
>
  • Search for 6
  • Search for 6 4 2
  • Search for 6 6 4 7 8
  • Search for 5 4 3 2 1
  • Search for 10 4 8 6 6 4 2 6 6 6
2. A search in array "1 2 3 4 5 6 7 8"
 
  • Search for 8 9 10
  • Search for 1 2 3 4 5 6 7 8 9 10
  • Search for 1 2 3 4 5 6 7 8 9 10 11
Added:
>
>
  • Search for 5 6 7

Solution

Revision 102016-09-29 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5

Due: Oct 13, 11:55pm

Instructions

Deleted:
<
<
  • Do one of the following problems (the other is due the next week)
 
  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
  • Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.
Changed:
<
<

Grading

Feature %
Program correctness and completeness with respect to defination 70%
Code Format (Indenting, variable names) 10%
Code Comments 10%
Turning in complete run of every function at least twice with difference values. 10%

Problem 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 two-column 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

N Count
4 2
3 3
2 2
1 4
-1 1
-12 4

Hint

>
>
  • You will need to use arrays
 
Changed:
<
<
It is MUCH easier to count 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


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"

Revision 92016-08-24 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5

Changed:
<
<

Due: Oct 19, 11:55pm

>
>

Due: Oct 13, 11:55pm

 

Instructions

  • Do one of the following problems (the other is due the next week)

Revision 82015-10-18 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5

Changed:
<
<

Due: Oct 17, 11:55pm

>
>

Due: Oct 19, 11:55pm

 

Instructions

  • Do one of the following problems (the other is due the next week)

Revision 72015-10-17 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5

Due: Oct 17, 11:55pm

Line: 14 to 14
 
Code Format (Indenting, variable names) 10%
Code Comments 10%
Turning in complete run of every function at least twice with difference values. 10%
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 two-column 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 two-column 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
 
-12 4

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.

Revision 62015-10-15 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5

Changed:
<
<

Due: Oct 15, 11:55pm

>
>

Due: Oct 17, 11:55pm

 

Instructions

Added:
>
>
  • Do one of the following problems (the other is due the next week)
 
  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
  • Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.

Grading

Line: 32 to 33
 
1 4
-1 1
-12 4
Added:
>
>

Hint

It 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

Revision 52015-10-06 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5

Changed:
<
<

Due: Oct 6, 11:55pm

>
>

Due: Oct 15, 11:55pm

 

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.

Revision 42015-10-05 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5

Due: Oct 6, 11:55pm

Line: 15 to 15
 
Turning in complete run of every function at least twice with difference values. 10%

Problems

Changed:
<
<
1. One problem we have encountered is using cin for numeric data. If we enter a non-nueric 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 cin, and returns both the integer and a true, but if the input is NOT an integer, it returns zero and false. This will allow us to know if the input number is an integer, and handle the situation of non-interger input smoothly.

The method we will employ

2. 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 two-column 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. 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 two-column 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
 
1 4
-1 1
-12 4
\ No newline at end of file
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 sub-sequence 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"

  • Search for 3
  • Search for 6 4 2
  • Search for 6 6 4 7 8
  • Search for 5 4 3 2 1
2. A search in array "1 2 3 4 5 6 7 8 9 10"

  • Search for 8 9 10
  • Search for 1 2 3 4 5 6 7 8 9 10
  • Search for 1 2 3 4 5 6 7 8 9 10 11

Revision 32015-10-05 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5

Due: Oct 6, 11:55pm

Line: 15 to 15
 
Turning in complete run of every function at least twice with difference values. 10%

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 two-column 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 non-nueric 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 cin, and returns both the integer and a true, but if the input is NOT an integer, it returns zero and false. This will allow us to know if the input number is an integer, and handle the situation of non-interger input smoothly.

The method we will employ

2. 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 two-column 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
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

Revision 22015-10-05 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 5

Due: Oct 6, 11:55pm

Line: 15 to 15
 
Turning in complete run of every function at least twice with difference values. 10%

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 two-column 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

N Count
4 2
3 3
2 2
1 4
-1 1
-12 4

Revision 12015-10-01 - JimSkon

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="WebHome"

Lab 5

Due: Oct 6, 11:55pm

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
  • Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.

Grading

Feature %
Program correctness and completeness with respect to defination 70%
Code Format (Indenting, variable names) 10%
Code Comments 10%
Turning in complete run of every function at least twice with difference values. 10%

Problems

1.

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback