You are to write a program that does the following:
1. Read a list with names and year born from a file into an array.
2. There will not be more than 30 names in the file.
3. Write a function that will sort the names with the correct year born. (A dual sort)
4. You must use a recursive quicksort (a quick sort).
5. After sorting, print out the alphabetical list with the age.
6. See the date-time program for how to get the current year.
The quicksort works as follows. Call quicksort with the arrays and min and max. If min=max the list has just one element and is thus sorted.

Otherwise use the first element from min to max as a pivot value. Partition the list (from min to max) so that all of the values less than or equal to the pivot value are before it and all of the values greater than or equal to the pivot value are after it. The pivot value is now in its proper place.

Call quicksort
to sort the list from min to pivot-1 and call quicksort to sort the list from pivot+1 to max.

Date and Time Program
#include <iostream>
#include <ctime>
#include <string>
using namespace std;
int main ()
{ time_t now = time(0); // get current time
struct tm* today = localtime(&now); // get struct filled out
string ampm="AM";
cout<<"the year is "<<today->tm_year + 1900<<endl; // year with century
cout<<"the month is "<<today->tm_mon+1<<endl; // month:January= 0
cout<< "the date is " << today->tm_mday<<endl; // day
int day=today->tm_wday; //day of week: Sunday=0;
switch(day) {
case 0:cout<<"Sunday\n"; break;
case 1:cout<<"Monday\n"; break;
case 2:cout<<"Tuesday\n"; break;
case 3:cout<<"Wednesday\n"; break;
case 4:cout<<"Thursday\n"; break;
case 5:cout<<"Friday\n"; break;
case 6:cout<<"Saturday\n"; break;
cout<<today->tm_wday<<endl; //day of week: Sunday=0
int hour=today->tm_hour;
if(hour>12) {
cout<<hour; // hours
cout<< ":" << today->tm_min; // minutes
cout<< ":" << today->tm_sec; // seconds

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <cstdlib>
#include <iostream>
#include <fstream>
#include "person.h"
using namespace std;

person lineToPerson(string line ){
    size_t i = line.find_first_of(",");
    person p (line.substr(0,i), atoi( line.substr(i + 1).c_str() )) ;   
    return p;

bool readFile(string file, person p[], int & size){
    fstream in;, ios::in);
    if (in.is_open()) {
       string line;
       size = 0;
       while (in>>line) {
            p[size] = lineToPerson(line);
       return true;
    return false;

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats