Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <random>
- using namespace std;
- static const char justletters[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
- int justLettersLength= sizeof(justletters) - 1;
- static const char tab[] =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
- int stringTab = sizeof(tab) - 1;
- string tabBZ[4] = {" ", "\n", "\t", "\r"};
- static const char alphanum[] =
- "0123456789"
- "!@#$%^&*"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
- string operacje[4] = {"NEW", "DEL", ">", "?"};
- int stringLength = sizeof(alphanum) - 1;
- #define SIZEO 10
- void wylosujNumer() {
- int iloscCharow = rand() % SIZEO + SIZEO;
- for (int i = 0; i < iloscCharow; i++) {
- int c = rand() % 10;
- cout << c;
- }
- }
- void wylosujID() {
- int iloscCharow = rand() % SIZEO + SIZEO;
- for (int i = 0; i < iloscCharow; i++) {
- int c = rand() % justLettersLength;
- cout << justletters[c];
- }
- iloscCharow = rand() % SIZEO + SIZEO;
- for (int i = 0; i < iloscCharow; i++) {
- int c = rand() % stringTab;
- cout << tab[c];
- }
- }
- void wylosujKomentarz() {
- int iloscCharow = rand() % SIZEO + SIZEO;
- cout << "$$";
- for (int i = 0; i < iloscCharow; i++) {
- int c = rand() % stringLength;
- cout << alphanum[c];
- }
- int d = rand() % 1000;
- if (d < 900) cout << "$$";
- }
- void wylosujBialyZnak() {
- int iloscCharow = rand() % SIZEO + SIZEO;
- for (int i = 0; i < iloscCharow; i++) {
- int c = rand() % 4;
- cout << tabBZ[c];
- }
- }
- void wylosujOperacje() {
- int operation = rand() % 4;
- string t = operacje[operation];
- if (operacje[operation] == ">") {
- int l = rand() % 1000;
- if (l < 950) {
- wylosujNumer();
- }
- } else if (operacje[operation] == "?") {
- int l = rand() % 1000;
- if (l < 990) {
- int p = rand() % 2;
- if (p == 0) cout << operacje[operation];
- wylosujNumer();
- if (p != 0) cout << operacje[operation];
- } else wylosujKomentarz();
- return;
- }
- cout << operacje[operation];
- int k = rand() % 1000;
- if (k < 990) wylosujBialyZnak();
- int p = rand() % 10000;
- if (p > 9900) return;
- if (operacje[operation] == "NEW") {
- wylosujID();
- } else if (operacje[operation] == "DEL") {
- int k = rand() % 1000;
- if (k > 10) {
- wylosujNumer();
- } else {
- wylosujID();
- }
- } else {
- wylosujNumer();
- }
- k = rand() % 1000;
- if (k < 990) wylosujBialyZnak();
- }
- int main() {
- long int seed;
- cin >> seed;
- srand(seed * time(NULL));
- int iloscLinii = rand() % 1000 + 1000;
- int p = rand() % 100;
- if (p < 95) cout << "NEW ID\n" << endl;
- for (int i = 0; i < iloscLinii; i++) {
- int j = rand() % 500;
- if (j > 300) wylosujKomentarz();
- wylosujOperacje();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement