Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <string>
- std::string randomstring(int len) {
- static long seed = time(0);
- seed += rand();
- srand(seed);
- std::string s;
- for(int i=0; i<len; ++i) {
- int r = rand() % 3;
- s.push_back(
- r == 0 ? rand()%(90-65) + 65
- : r == 1 ? rand()%(57-48) + 48
- : rand()%(122-97) + 97
- );
- }
- return s;
- }
- int main() {
- for(int i=0; i<20 ;i++)
- std::cout<<i<<" - "<<randomstring(10)<<std::endl;
- std::cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement