Advertisement
_takumi

generator

Apr 12th, 2023
905
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <ctime>
  4. #include <fstream>
  5. #include <string>
  6. #include <vector>
  7.  
  8. int main(int argc, char *argv[]) {
  9.     const std::string smallalphabet = "ab";
  10.     const std::string largealphabet = "qwer";
  11.     srand(time(nullptr));
  12.     const int SMALL_FILE_SIZE = 10000;
  13.     const int LARGE_FILE_SIZE = 100000;
  14.     std::ofstream smallfile("smallfile.txt");
  15.     std::ofstream largefile("largefile.txt");
  16.     std::ofstream patterns("patterns.txt");
  17.     std::string smallstring;
  18.     std::string largestring;
  19.     for (int i = 0; i < SMALL_FILE_SIZE; ++i) {
  20.         smallstring += smallalphabet[rand() % 2];
  21.     }
  22.     for (int i = 0; i < LARGE_FILE_SIZE; ++i) {
  23.         largestring += largealphabet[rand() % 4];
  24.     }
  25.     smallfile << smallstring << std::endl;
  26.     largefile << largestring << std::endl;
  27.     for (int sz = 100; sz <= 3000; sz += 100) {
  28.         int small_i = rand() % (SMALL_FILE_SIZE - sz);
  29.         int large_i = rand() % (LARGE_FILE_SIZE - sz);
  30.         patterns << smallstring.substr(small_i, sz) << "," <<
  31.                     largestring.substr(large_i, sz) << std::endl;
  32.     }
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement