Guest User

Untitled

a guest
Apr 28th, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <fstream>
  4. #include <string>
  5. #include <iomanip>
  6. #include <vector>
  7. #include <sstream>
  8. #include "BinomialQueue.h"
  9. using namespace std;
  10.  
  11. template<typename type>
  12. void myQueue(const string& createQueue, const string& compare, type myTree){
  13.  
  14.     ifstream file;
  15.     file.open(createQueue);
  16.     if(file.is_open()){
  17.         int fileLine;
  18.         // Reads the file
  19.         while(file >> fileLine){
  20.             // Inserts the number into the tree
  21.             myTree.insert(fileLine);
  22.         }
  23.         cout << "Success inserting " << numOfElement << " elements into the queue. The minimum element is " << myTree.findMin() << endl;
  24.     }
  25.     else{
  26.         cout << "No file exist \n";
  27.     }
  28.     file.close();
  29.  
  30.     // Open second file
  31.     ifstream file2;
  32.     file2.open(compare);
  33.     if(file2.is_open()){
  34.         int fileLine;
  35.         while(file2 >> fileLine){
  36.             // Checks if the number can be deleted
  37.             if(myTree.deleteItem(fileLine) == true){
  38.                 cout << left << setw(10) << fileLine  << " Deletion successful! - New minimum is: "  << myTree.findMin() << endl;
  39.             }
  40.             else{
  41.                 cout << left << setw(10) << fileLine  << " Serious problem with deletion!" << endl;
  42.             }
  43.         }
  44.     }
  45.     else{
  46.         cout << "No file exist \n";
  47.     }
  48.     file2.close();
  49.  
  50. }
  51.  
  52. int main(int argc, char** argv){
  53.  
  54.     if(argc != 3){
  55.         cout << "Invalid parameters" << endl;
  56.         return 0;
  57.     }
  58.  
  59.     const string createFile = argv[1];
  60.     const string compareFile = argv[2];
  61.     cout << "Input file is: " << createFile << " & Check file is: " << compareFile << '\n' << '\n';
  62.     BinomialQueue<int>someQueue;
  63.     myQueue(createFile, compareFile, someQueue);
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment