Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <random>
- #include <string>
- #include <fstream>
- using namespace std;
- string random_string(size_t length )
- {
- static const string alphabet = "abcdefghijklmnopqrstuvwxyz" ;
- static default_random_engine rng( time(nullptr) ) ;
- static uniform_int_distribution<size_t> distribution( 0, alphabet.size() - 1 ) ;
- string str ;
- while( str.size() < length ) str += alphabet[ distribution(rng) ] ;
- return str ;
- }
- int main()
- {
- srand (time(NULL));
- ofstream myfile;
- myfile.open ("string.txt");
- //for( size_t i = 10 ; i < 40 ; i += 3 ) cout << random_string(i) << '\n' ;
- for(int k = 0; k < 10000; k++)
- {
- int range = rand() % 20 + 2;
- myfile << random_string(range) << '\n';
- }
- myfile.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement