Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- string phraseConstruct();
- int main()
- {
- int i;
- string randPhrase;
- string hide;
- randPhrase = phraseConstruct();
- hide = randPhrase;
- for(i=0;i<hide.size();i++)
- {
- hide[i]='*';
- }
- cout<<hide;
- return 0;
- }
- string phraseConstruct()
- {
- string randomPhrase;
- int totalWords;
- string wordOne;
- string wordTwo;
- string wordThree;
- string wordFive;
- string wordFour;
- string wordArray[30]= {"random","monkey","tommorrow","fun","stupid","phone","airplane","love","medical","television","programming","computer","tomato","mouse","olive","eraser","donkey","lipstick","basket","eggs","socks","birdhouse","donuts","glasses","chair","wand","backpack","turtle","rapper","chapstick"};
- srand(time(0));
- totalWords = (1 + (rand()%5));
- cout<<"The total number of words in this phrase will be: "<<totalWords<<"\n";
- if(totalWords==1)
- {
- wordOne = wordArray[(rand()%30)];
- }
- else if(totalWords==2)
- {
- wordOne = wordArray[(rand()%30)];
- wordTwo = wordArray[(rand()%30)];
- }
- else if(totalWords==3)
- {
- wordOne = wordArray[(rand()%30)];
- wordTwo = wordArray[(rand()%30)];
- wordThree = wordArray[(rand()%30)];
- }
- else if(totalWords==4)
- {
- wordOne = wordArray[(rand()%30)];
- wordTwo = wordArray[(rand()%30)];
- wordThree = wordArray[(rand()%30)];
- wordFour = wordArray[(rand()%30)];
- }
- else if(totalWords==5)
- {
- wordOne = wordArray[(rand()%30)];
- wordTwo = wordArray[(rand()%30)];
- wordThree = wordArray[(rand()%30)];
- wordFour = wordArray[(rand()%30)];
- wordFive = wordArray[(rand()%30)];
- }
- randomPhrase = wordOne + " " + wordTwo + " " + wordThree + " " + wordFour + " " + wordFive;
- return (randomPhrase);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement