Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- char* PrintWow(const char* Wow[], int wowsize)
- {
- int index = std::rand() % wowsize;
- const char* word = Wow[index];
- int size1 = strlen(Wow[index]);
- index = 0;
- while (index < 3)
- {
- index = std::rand() % 10;
- }
- int size2 = index;
- char* rword = new char[size1 + size2 + 1];
- int count = 0;
- for (count; count < size1; count++)
- {
- rword[count] = word[count];
- }
- rword[count] = ' ';
- count += 1;
- for (count; count < size1 + size2 + 1; count++)
- {
- rword[count] = '!';
- }
- rword[count++] = '\0';
- return rword;
- }
- char* PrintSubj(const char* ObjSubj[],int objsubjsize, bool array[][2])
- {
- bool tmp = 0;
- int index = 0;
- while (tmp == 0)
- {
- index = std::rand() % 5;
- tmp = array[index][1];
- }
- const char* word = ObjSubj[index];
- int wordlen = std::strlen(word);
- char* rword = new char[wordlen];
- for (int i = 0; i < wordlen; i++)
- {
- if (i == 0)
- {
- rword[i] = word[i];
- rword[i] = rword[i] - 32;
- }
- else rword[i] = word[i];
- }
- rword[wordlen] = '\0';
- return rword;
- }
- char* PrintAction(const char* Actions[],int actions)
- {
- int index = std::rand() % actions;
- const char* word = Actions[index];
- int size = strlen(Actions[index]);
- char* rword = new char[size];
- for (size_t i = 0; i < size; i++)
- {
- rword[i] = word[i];
- }
- rword[size] = '\0';
- return rword;
- }
- char* PrintObj(const char* ObjSubj[], int objsubjsize, bool array[][2])
- {
- bool tmp = 0;
- int index = 0;
- while (tmp == 0)
- {
- index = std::rand() % 5;
- tmp = array[index][0];
- }
- const char* word = ObjSubj[index];
- int wordlen = std::strlen(word);
- char* rword = new char[wordlen];
- for (int i = 0; i < wordlen; i++)
- {
- rword[i] = word[i];
- }
- rword[wordlen] = '\0';
- return rword;
- }
- int main()
- {
- srand(time(nullptr));
- int nnn;
- int cnt = 0;
- std::cin >> nnn; // Just for generating the needed amount of headlines;
- const char* Wow[] = {"Shok", "Skandal", "Ne4uvana naglost"};
- int wowsize = 3;
- const char* ObjSubj[] = { "rqpa", "baba", "kmet", "bager", "sklad" };
- int objsubjsize = 5;
- const char* Actions[] = { "sgazi", "zadiga", "namiga na", "precakva", "tarashi" };
- int actions = 5;
- // Here I represent the ohject/subject relation through boolean values in a matrix,
- bool relation[5][2];
- for (int i = 0; i < 5; i++)
- {
- for (size_t j = 0; j < 2; j++)
- {
- relation[i][j] = 1;
- }
- }
- relation[4][1] = false;
- char* output;
- int len1;
- int len2;
- int len3;
- int len4;
- int count = 0;
- char* part1;
- char* part2;
- char* part3;
- char* part4;
- while (cnt < nnn)
- {
- part1 = PrintWow(Wow, wowsize);
- part2 = PrintSubj(ObjSubj, objsubjsize, relation);
- part3 = PrintAction(Actions, actions);
- part4 = PrintObj(ObjSubj, objsubjsize, relation);
- len1 = strlen(part1);
- len2 = strlen(part2);
- len3 = strlen(part3);
- len4 = strlen(part4);
- output = new char[len1 + len2 + len3 + len4 + 3];
- for (int i = 0; i < len1; i++)
- {
- output[count++] = part1[i];
- }
- output[count++] = ' ';
- for (int i = 0; i < len2; i++)
- {
- output[count++] = part2[i];
- }
- output[count++] = ' ';
- for (int i = 0; i < len3; i++)
- {
- output[count++] = part3[i];
- }
- output[count++] = ' ';
- for (int i = 0; i < len4; i++)
- {
- output[count++] = part4[i];
- }
- output[count++] = '\0';
- count = 0;
- std::cout << output <<std::endl;
- delete[] part1;
- //delete[] part2;
- //delete[] part3;
- //delete[] part4;
- //delete[] output;
- cnt += 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement