getivan

FREE Mass Keyword Multiplier C++ Compiler Code

Oct 8th, 2019
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, const char *argv[])
  9. {
  10.     if (argc <= 2)
  11.     {
  12.         cerr << "Usage: " << argv[0] << " FILENAME1 FILENAME2 [FILENAME3 [FILENAME4 [...]]\n";
  13.         return -1;
  14.     }
  15.     auto lists = new vector<string> [argc-1];
  16.     for (int i=1; i<argc; i++)
  17.     {
  18.         ifstream file(argv[i]);
  19.         if (!file.good())
  20.         {
  21.             cerr << "Error openening file \"" << argv[i] << "\"\n";
  22.             return -1;
  23.         }
  24.         lists[i-1].clear();
  25.         string line;
  26.         while (getline(file, line))
  27.         {
  28.             int length = line.length();
  29.             if (line[length-1] == '\n')
  30.                 length--;
  31.             if (line[length-1] == '\r')
  32.                 length--;
  33.            
  34.             lists[i-1].push_back(line.substr(0, length));
  35.         }
  36.     }
  37.  
  38.     auto current = new int [argc-1];
  39.     for (int i=0; i<argc-1; i++)
  40.         current[i] = 0;
  41.  
  42.     for (;;)
  43.     {
  44.         for (int i=0; i<argc-1; i++)
  45.         {
  46.             cout << lists[i][current[i]];
  47.             if (i < argc-2)
  48.                 cout << ' ';
  49.         }
  50.         cout << endl;
  51.  
  52.         for (int j=argc-2;;)
  53.         {
  54.             if (++current[j] < lists[j].size())
  55.                 break;
  56.             current[j] = 0;
  57.             if (--j < 0)
  58.                 return 0;
  59.         }
  60.     }
  61. }
Add Comment
Please, Sign In to add comment