C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Shot put reward

In the game of shot put, a heavy ball is thrown by players to the farthe academy, the coach offers some chocolates to the players performing them. The players stand in a line and take turns for throwing the ball or who makes an attempt knows his/her score after the attempt. A player can ask the score of the player just adjacent to him/her and th player. The coach decides to give chocolates in such a way that no pla fewer chocolates than he/she should get. Find the minimum chocolates

Input Specification:

input1: Number of players

input2: Integer array containing the scores of players

Output Specification:

Return the minimum number of chocolates given to each player by the

coach.

Example 1:

input1: 5

input2: (35,14,42,44,39}

Output: 6

Type here to search
Shot put reward
Output 6,14

Write a program that accepts 10 values from the user at the keyboard and stores them in an array .Pass the array and it's size to a function that determines and displays the smallest and largest of the 10 values.


Write a method that receives elapsed time in seconds as a parameter.The method should then display the elapsed time in hours , minutes and seconds.For example , If the elapsed time is 9630 seconds , then the method should display 2:40:30 . Write a main() method that will prompt a user for elapsed time of an event in seconds, And use received value to demonstrate that the method works correctly.


Implement the following function. You may use the stack template class and the
stack operations of push, pop, peek, is_empty, and size. You may also use cin.peek( )
and use "cin>>i" to read an integer.
int evaluate_postfix_from_cin( )
// Precondition (Which is not checked): The next input line of cin is a
// properly formed postfix expression consisting of integers,
// the binary operations + and -, and spaces.
// Postcondition: The function has read the next input line (including
// the newline) and returned the value of the postfix expression.
{
int i;
stack<int> s;
Task 1:

Complete the body of this function. You do not need to check the precondition. You
may use the stack template class
bool balanced(const char p[ ], size_t n)
// Precondition: p[0]...p[n-1] contains n characters, each of which
// is '(', ')', '{' or '}'.
// Postcondition: The function returns true if the characters form a
// sequence of correctly balanced parentheses with each '(' matching
// a ')' and each '{' matching a '}'. Note that a sequence such as
// ( { ) } is NOT balanced because when we draw lines to match the
// parentheses to their partners, the lines cross each other. On the
// other hand, ( { } ) and { ( ) } are both balanced.
Task2:
Add the function to Task 1,Write a function that will swap pairs of elements in a given singlylinked list. Note that you have to actually swap the elements, not just the values, and that you
should modify the list in place (i.e. you should not create a copy of the list). For instance, the list
1->2->3->4->5->6->… becomes 2->1->4->3->6->5->…
Write a SortedInsert() function which given a list that is sorted in increasing order, and a single
node, inserts the node into the correct sorted position in the list. Use Insert() function of task 1
allocates a new node to add to the list, SortedInsert() takes an existing node, and just rearranges
pointers to insert it into the list.
Add a function to task 1 which accepts a linear linked list List and converts it to a circular linked
list.
Where List is a pointer to the front of the list.
Prototype of the function is as following
Node *Convert( Node *List)
The function below should insert a value as the head of a given UNORDERED linked list. Be
careful to first search for the given value. The value is inserted only if it does not exist in the
list. If the value exists, the function does nothing. Use Linked list implementation of Task 1 to
make this function run. Write down the code of insert function run the code, take snap shot
and paste it in your document.
struct Node{
int data;
Node* next;
};
The function prototype is given. Implement the function.
void insert(Node* &head, int value);
Your task is to design Dynamic Array (Class).
What is Dynamic Array?
Which can grow and shrink at run time.
Your class should work for one and two dimensional Arrays
The class should enable the user to perform the following tasks:
1) Create a dynamic array of size specified by the user. Use an integer to keep track of the
size
2) Ask the user for numbers to insert until the user presses -1. Insert each value in the array.
Create a new larger array when the array is full, copy all data to the new array, and release
the memory for the old array. Print the array after each insert.
3) Ask the user for any numbers to delete until the user presses -1. Find the index of the
entered value in the original array and then remove that index from the original array.
Stop when the array is empty or when the user presses -1. Keep on reducing the array size
and print the array after each removal.
4) Make sure to release any allocated memory not yet released.
LATEST TUTORIALS
APPROVED BY CLIENTS