/****************************************************** ** Name: ** Filename: Radix.cpp ** Project #: ** Project Description: This program will read an input file called radixdata.txt, which contains a list of numbers that are six digits long. The computer will use this input and perform a radix sort of the numbers using the queue class. The results of the sort will then be printed to the screen. ** Output:All the numbers inputed from the radixdata.txt printed to the screen in numerical order. ** Input: A group of numbers six digits in length in a file called radixdata.txt. ** Algorithm: Instruct user on program purpose. Read data in from file radixdata.txt Use while loop Insert data in Q holder Transfer holder to tempholder Print out tempholder Perform RadixSort using sorter[] Use a for loop to read through each digit starting with the last Use a for loop to read all entries in sorter place number from holder into associated sorter Use a for loop to read through all the sorter Transfer data from the sorter to the holder Print the sorted contents of Q holder End ******************************************************/ // Include files #include // used for cin, cout #include #include // file input/output #include // class for queue's #include // used for string's using namespace std; // Global Type Declarations typedef queue Q; // Function Prototypes void instruct(void); void pause (); int main() { // Declaration section Q holder, tempholder, sorter[10]; const int Digits = 6; // Number of digits per item char numInput[Digits]; // Stores data input int bin; // Stores digits of queue int run1; // Records runs for print int run2; // Records runs for print // Executable section instruct (); cout << "Inserting Data In The Queue\n" ; cout << "----------------------------\n" << endl; ifstream inDataFile( "radixdata.txt", ios::in); //Open Data File if ( !inDataFile ) { cerr << "File could not be opened\n"; exit(1); } inDataFile >> numInput; //Read In Data while ( !inDataFile.eof()) //Stop When End Of File Reached { holder.push(numInput); //Put Data In Queue inDataFile >> numInput; //Read In Next Line Of Data } run1 = 0; tempholder = holder; //Copy holder queue to tempholder cout << "Data In The Queue\n\n"; while (!tempholder.empty()) { //Print Out Unsorted Queue cout << tempholder.front() << " "; tempholder.pop(); run1++; if ( run1 % 10 == 0 ) cout < - 1; i-- ) //Begin Sort Of Queue Using Sorter { while (!holder.empty()) { bin = (static_cast(holder.front().at(i))) - 48; sorter[bin].push(holder.front()); holder.pop(); } for ( int j = 0; j <= 9; j++ ) { while (!sorter[j].empty()) //Run Through Sorter { holder.push(sorter[j].front());//Push Front Digit From Holder sorter[j].pop();} //Pop Out From Sorter } } run2 = 0; cout << "Data In The Sorted Queue\n\n"; while (!holder.empty()) { //Print Out Sorted Queue cout << holder.front() << " "; holder.pop(); run2++; if ( run2 % 10 == 0 ) cout <