PDA

View Full Version : Help!!! Several topic is C++


shawaka
12-19-2006, 07:55 PM
Here are a few questions in which I am having great difficulty in finding the answers. If anyone can help with any of them it will be greatly appreiciated. Thanks so much!!!:)

Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the second with the next to the last, and so on, all the way to the middle of the array.


Given an array a , an int variable n containing the number of elements in a , and two other int variables, k and temp , write a loop that reverses the elements of the array.


Do not use any other variables besides a , n , k , and temp .



#2 Given:
an int variable k ,
an int array currentMembers that has been declared and initialized,
an int variable nMembers that contains the number of elements in the array,
an int variable memberID that has been initialized, and
a bool * variable isAMember ,


Write code that assigns true to isAMember if the value of memberID can be found in currentMembers , and that assigns false to isAMember otherwise.

Use only k , currentMembers , nMembers , and isAMember .




#3 You are given an int variable k , an int array zipcodeList that has been declared and initialized, an int variable nZips that contains the number of elements in zipcodeList , and a bool *variable duplicates .


Write some code that assigns true to duplicates if there are two adjacent elements in the array that have the same value, and that assigns false to duplicates otherwise.

Use only k , zipcodeList , nZips , and duplicates .


#4 You are given two int variables j and k , an int array zipcodeList that has been declared and initialized, an int variable nZips that contains the number of elements in zipcodeList , and a bool *variable duplicates .


Write some code that assigns true to duplicates if any two elements in the array have the same value, and that assigns false to duplicates otherwise.

Use only j , k , zipcodeList , nZips , and duplicates .



#5 Given
an int variable k ,
an int array incompletes that has been declared and initialized,
an int variable nIncompletes that contains the number of elements in the array,
an int variable studentID that has been initialized, and
an int variable numberOfIncompletes ,


Write code that counts the number of times the value of studentID appears in incompletes and assigns this value to numberOfIncompletes .


You may use only k , incompletes , nIncompletes , studentID , and numberOfIncompletes .




#6 An array of integers named parkingTickets has been declared and initialized to the number of parking tickets given out by the city police each day since the beginning of the current year. (Thus, the first element of the array contains the number of tickets given on January 1; the last element contains the number of tickets given today.)

A variable named ndays has been declared and initialized to hold the size of the array. (Thus, if today were January 18, ndays would have the value 18; if today were February 3, ndays would have the value 34.)

In addition, a variable named mostTickets has been declared, along with a variable k .

Without using any additional variables, and without changing the values of ndays or the elements of the parkingTickets array, write some code that results in mostTickets containing the largest value found in parkingTickets .

oracleguy
12-20-2006, 12:15 AM
Well you didn't post what you have so far for any of them or what parts you are having difficulty with. We will not just do the whole assignment for you.

What have you got thus far?