Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <iomanip>
- #include <vector>
- #include <sstream>
- #include "BinomialQueue.h"
- using namespace std;
- template<typename type>
- void myQueue(const string& createQueue, const string& compare, type myTree){
- ifstream file;
- file.open(createQueue);
- if(file.is_open()){
- int fileLine;
- // Reads the file
- while(file >> fileLine){
- // Inserts the number into the tree
- myTree.insert(fileLine);
- }
- cout << "Success inserting " << numOfElement << " elements into the queue. The minimum element is " << myTree.findMin() << endl;
- }
- else{
- cout << "No file exist \n";
- }
- file.close();
- // Open second file
- ifstream file2;
- file2.open(compare);
- if(file2.is_open()){
- int fileLine;
- while(file2 >> fileLine){
- // Checks if the number can be deleted
- if(myTree.deleteItem(fileLine) == true){
- cout << left << setw(10) << fileLine << " Deletion successful! - New minimum is: " << myTree.findMin() << endl;
- }
- else{
- cout << left << setw(10) << fileLine << " Serious problem with deletion!" << endl;
- }
- }
- }
- else{
- cout << "No file exist \n";
- }
- file2.close();
- }
- int main(int argc, char** argv){
- if(argc != 3){
- cout << "Invalid parameters" << endl;
- return 0;
- }
- const string createFile = argv[1];
- const string compareFile = argv[2];
- cout << "Input file is: " << createFile << " & Check file is: " << compareFile << '\n' << '\n';
- BinomialQueue<int>someQueue;
- myQueue(createFile, compareFile, someQueue);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment