C++

profilexql338

 

C++

In this assignment you will be writing several functions to practice your skills in writing recursive functions and using stacks/queues.

First, start by writing and testing the following functions:

[15 pts] Write a recursive function to display the digits of an arbitrary integer in reverse order. That is, if called with the integer 2364, it would display 4 6 3 2.

[15 pts] Write a function that takes in a string and reverses it using a stack. Use an STL stack.

[15 pts] Write a recursive function that performs selection sort. Each recursive step should perform another pass on the array.

[15 pts] Write a recursive function that performs bubble sort. Each recursive step should perform another pass on the array.

Then, in your main body, test these programs.

  1. 1)  [5 pts] Read in a number from the user. Call your reverse function and output the integer in reverse.

  2. 2)  [5 pts] Prompt the user for a string, reverse it with your function and output it to the screen.

  3. 3)  [5 pts] Create an array of 10 random numbers, display it to the screen, then sort it with your recursive selection sort. Then output the results to the screen.

  4. 4)  [5 pts] Create a new array of 10 random numbers, display it to the screen, then sort it with your recursive bubble sort and output the results to the screen. 

    • 9 years ago
    • 5
    Answer(0)
    Bids(0)