Advertisement
sharmap

project

Aug 1st, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstdlib>
  4. #include <ctime>
  5.  
  6. using namespace std;
  7.  
  8. string phraseConstruct();
  9.  
  10.  
  11.  
  12. int main()
  13. {
  14. int i;
  15.  
  16. string randPhrase;
  17. string hide;
  18.  
  19. randPhrase = phraseConstruct();
  20. hide = randPhrase;
  21.  
  22. for(i=0;i<hide.size();i++)
  23. {
  24.     hide[i]='*';
  25. }
  26.  
  27. cout<<hide;
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.     return 0;
  35. }
  36.  
  37. string phraseConstruct()
  38. {
  39.     string randomPhrase;
  40.     int totalWords;
  41.     string wordOne;
  42.     string wordTwo;
  43.     string wordThree;
  44.     string wordFive;
  45.     string wordFour;
  46.  
  47.     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"};
  48.  
  49.     srand(time(0));
  50.  
  51.     totalWords = (1 + (rand()%5));
  52.  
  53.     cout<<"The total number of words in this phrase will be: "<<totalWords<<"\n";
  54.  
  55.     if(totalWords==1)
  56.     {
  57.         wordOne = wordArray[(rand()%30)];
  58.     }
  59.     else if(totalWords==2)
  60.     {
  61.     wordOne = wordArray[(rand()%30)];
  62.     wordTwo = wordArray[(rand()%30)];
  63.     }
  64.     else if(totalWords==3)
  65.     {
  66.     wordOne = wordArray[(rand()%30)];
  67.     wordTwo = wordArray[(rand()%30)];
  68.     wordThree = wordArray[(rand()%30)];
  69.     }
  70.     else if(totalWords==4)
  71.     {
  72.     wordOne = wordArray[(rand()%30)];
  73.     wordTwo = wordArray[(rand()%30)];
  74.     wordThree = wordArray[(rand()%30)];
  75.     wordFour = wordArray[(rand()%30)];
  76.     }
  77.     else if(totalWords==5)
  78.     {
  79.     wordOne = wordArray[(rand()%30)];
  80.     wordTwo = wordArray[(rand()%30)];
  81.     wordThree = wordArray[(rand()%30)];
  82.     wordFour = wordArray[(rand()%30)];
  83.     wordFive = wordArray[(rand()%30)];
  84.  
  85.     }
  86.     randomPhrase = wordOne + " " + wordTwo + " " + wordThree + " " + wordFour + " " + wordFive;
  87.  
  88.  
  89.  
  90.     return (randomPhrase);
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement