Write a function called max consecutive integers that


1. set the marker U for the unsorted section at the end of the list (U is an integer index value)

2. while the unsorted section has more than one element do steps 3 through 7

3. set the current element marker C at the second element of the list (C is an integer index value)

4. while C has not passed U do steps 5 and 6

5. if the item at position C is Less than the item to its left then exchange these two items

6. move C to the right one position

7. move U left one position

8. stop

Your implementation for this function may NOT use strcpy ( ) . You may only exchange or swap pointers, but NOT actually make copies of the strings!

3. Write a recursive function called sum_primes () that accepts an unsigned integer, n, as an argument, and returns the sum of all primes from 2 to n. You must use recursion to solve this problem!

4. Write a function called smallest_sum_sequence ( ) that accepts an array of signed integers and the number of items in the array as arguments, and returns the smallest sum of a sequence of numbers in the array. A sequence is defined as a single item or multiple items that are in adjacent memory Locations.

5. Write a function called max_consecutive_integers () that accepts a two-dimensional array of signed integers, the number of rows, the number of columns as input parameters, and two pointers as output parameters (one of these pointers is actually a pointer to a pointer, i.e. two stars!). The function finds the maximum consecutive sequence of one integer. The first pointer stores the address the start of the maximum consecutive sequence of the same integer. The second indirectly stores the number the same consecutive integers in a row. These sequences may wrap from one row to the next. For example ([$xxxx] denotes address value):

Row/Column

0

1

2

3

4

0

-5

6

0

P         2

2                   .•

 

[$1000]

[$1004]

[$1008]

[$1012]

[$1016]

1

2

2

2

9

3

 

[$1020]

[$1024]

[$1028]

[$1032]

[$1036]

2

3

3

2

1

-8

 

[$1040]

[$1044]

[$1048]

[$1052]

[$1056]

3

7

-2

6

0

4

 

[$1060]

[$1064]

[$1068]

[$1072]

[$1076]

The function should store the address of row 0, column 3 ($1012) via the first pointer, and 5 (2, 2, 2, 2, 2) indirectly via the second pointer.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Write a function called max consecutive integers that
Reference No:- TGS01381645

Now Priced at $60 (50% Discount)

Recommended (93%)

Rated (4.5/5)