Want more features on Pastebin? Sign Up, it's FREE!
Guest

Code from the dark ages

By: a guest on Apr 23rd, 2011  |  syntax: C++  |  size: 29.04 KB  |  views: 56,598  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /* Hangman v1.0 */
  2.  
  3. #include <iostream.h>
  4. using namespace std;
  5.  
  6. // FUNCTIONS
  7.  
  8. void getword(void);
  9. void getword2(void);
  10. void getword3(void);
  11. void easy(void);
  12. void normal(void);
  13. void hard(void);
  14. void checkletter(void);
  15. void checkletter2(void);
  16. void checkletter3(void);
  17. int main();
  18.  
  19. // VARIABLES
  20.  
  21. bool runagain = false;
  22. char again = '0';
  23. int worddone = 0;
  24. char let1 = '0';
  25. char let2 = '0';
  26. char let3 = '0';
  27. char let4 = '0';
  28. char let5 = '0';
  29. char let6 = '0';
  30. char let7 = '0';
  31. char let8 = '0';
  32. char let9 = '0';
  33. char let10 = '0';
  34. char let11 = '0';
  35. char let12 = '0';
  36. char let13 = '0';
  37. int let1done = 0;
  38. int let2done = 0;
  39. int let3done = 0;
  40. int let4done = 0;
  41. int let5done = 0;
  42. int let6done = 0;
  43. int let7done = 0;
  44. int let8done = 0;
  45. int let9done = 0;
  46. int let10done = 0;
  47. int let11done = 0;
  48. int let12done = 0;
  49. int let13done = 0;
  50. char hang1[30] = "             ______   \n";
  51. char hang2[30] = "            |      |  \n";
  52. char hang3[30] = "            |       \n";
  53. char hang4[30] = "            |       \n";
  54. char hang5[30] = "            |       \n";
  55. char hang6[30] = "            |\n";
  56. char hang11[30] = "             ______   \n";
  57. char hang12[30] = "            |      |  \n";
  58. char hang13[30] = "            |      O\n";
  59. char hang14[30] = "            |       \n";
  60. char hang15[30] = "            |       \n";
  61. char hang16[30] = "            |\n";
  62. char hang21[30] = "             ______   \n";
  63. char hang22[30] = "            |      |  \n";
  64. char hang23[30] = "            |      O\n";
  65. char hang24[30] = "            |      |\n";
  66. char hang25[30] = "            |       \n";
  67. char hang26[30] = "            |\n";
  68. char hang31[30] = "             ______   \n";
  69. char hang32[30] = "            |      |  \n";
  70. char hang33[30] = "            |      O\n";
  71. char hang34[30] = "            |    - |\n";
  72. char hang35[30] = "            |       \n";
  73. char hang36[30] = "            |\n";
  74. char hang41[30] = "             ______   \n";
  75. char hang42[30] = "            |      |  \n";
  76. char hang43[30] = "            |      O\n";
  77. char hang44[30] = "            |    - | -\n";
  78. char hang45[30] = "            |       \n";
  79. char hang46[30] = "            |\n";
  80. char hang51[30] = "             ______   \n";
  81. char hang52[30] = "            |      |  \n";
  82. char hang53[30] = "            |      O\n";
  83. char hang54[30] = "            |    - | -\n";
  84. char hang55[30] = "            |     / \n";
  85. char hang56[30] = "            |\n";
  86. char hang61[30] = "             ______   \n";
  87. char hang62[30] = "            |      |  \n";
  88. char hang63[30] = "            |      O\n";
  89. char hang64[30] = "            |    - | -\n";
  90. char hang65[30] = "            |     / \\ ""\n";
  91. char hang66[30] = "            |\n";
  92. char blank1;
  93. char blank2;
  94. char blank3;
  95. char blank4;
  96. char blank5;
  97. char blank6;
  98. char blank7;
  99. char blank8;
  100. char blank9;
  101. char blank10;
  102. char blank11;
  103. char blank12;
  104. char blank13;
  105. int blankcount;
  106. int lettercount;
  107. char guess;
  108. int hangercount = 0;
  109. string guessword;
  110.  
  111.  
  112. // GET WORD
  113.  
  114. void getword(void) {
  115.  
  116.   string words[10] = {
  117.             "that",
  118.             "help",
  119.             "rent",
  120.             "chair",
  121.             "clock",
  122.             "book",
  123.             "rose",
  124.             "table",
  125.             "video",
  126.             "room"};
  127.  
  128.     int j;
  129.     const int N = 10;
  130.  
  131.     srand( (unsigned)time( NULL ) );
  132.  
  133.     for (j = 0; j < 10; j++) {
  134.         rand();
  135.     }
  136.  
  137.   j = (int) N * rand() / (RAND_MAX + 1.0);
  138.  
  139.   guessword = words[j];
  140.  
  141.  
  142.   if(guessword == "that") {
  143.   lettercount = 4;
  144.   blankcount = 4;
  145.   blank1 = '_';
  146.   blank2 = '_';
  147.   blank3 = '_';
  148.   blank4 = '_';
  149.   blank5 = '_';
  150.   let1 = 't';
  151.   let2 = 'h';
  152.   let3 = 'a';
  153.   let4 = 't';
  154.   }
  155.   else if(guessword == "help") {
  156.   lettercount = 4;
  157.   blankcount = 4;
  158.   blank1 = '_';
  159.   blank2 = '_';
  160.   blank3 = '_';
  161.   blank4 = '_';
  162.   blank5 = '_';
  163.   let1 = 'h';
  164.   let2 = 'e';
  165.   let3 = 'l';
  166.   let4 = 'p';
  167.   }
  168.   else if(guessword == "rent") {
  169.   lettercount = 4;
  170.   blankcount = 4;
  171.   blank1 = '_';
  172.   blank2 = '_';
  173.   blank3 = '_';
  174.   blank4 = '_';
  175.   blank5 = '_';
  176.   let1 = 'r';
  177.   let2 = 'e';
  178.   let3 = 'n';
  179.   let4 = 't';
  180.   }
  181.   else if(guessword == "chair") {
  182.   lettercount = 5;
  183.   blankcount = 5;
  184.   blank1 = '_';
  185.   blank2 = '_';
  186.   blank3 = '_';
  187.   blank4 = '_';
  188.   blank5 = '_';
  189.   let1 = 'c';
  190.   let2 = 'h';
  191.   let3 = 'a';
  192.   let4 = 'i';
  193.   let5 = 'r';
  194.   }
  195.   else if(guessword == "clock") {
  196.   lettercount = 5;
  197.   blankcount = 5;
  198.   blank1 = '_';
  199.   blank2 = '_';
  200.   blank3 = '_';
  201.   blank4 = '_';
  202.   blank5 = '_';
  203.   let1 = 'c';
  204.   let2 = 'l';
  205.   let3 = 'o';
  206.   let4 = 'c';
  207.   let5 = 'k';
  208.   }
  209.   else if(guessword == "book") {
  210.   lettercount = 4;
  211.   blankcount = 4;
  212.   blank1 = '_';
  213.   blank2 = '_';
  214.   blank3 = '_';
  215.   blank4 = '_';
  216.   blank5 = '_';
  217.   let1 = 'b';
  218.   let2 = 'o';
  219.   let3 = 'o';
  220.   let4 = 'k';
  221.   }
  222.   else if(guessword == "rose") {
  223.   lettercount = 4;
  224.   blankcount = 4;
  225.   blank1 = '_';
  226.   blank2 = '_';
  227.   blank3 = '_';
  228.   blank4 = '_';
  229.   blank5 = '_';
  230.   let1 = 'r';
  231.   let2 = 'o';
  232.   let3 = 's';
  233.   let4 = 'e';
  234.   }
  235.   else if(guessword == "table") {
  236.   lettercount = 5;
  237.   blankcount = 5;
  238.   blank1 = '_';
  239.   blank2 = '_';
  240.   blank3 = '_';
  241.   blank4 = '_';
  242.   blank5 = '_';
  243.   let1 = 't';
  244.   let2 = 'a';
  245.   let3 = 'b';
  246.   let4 = 'l';
  247.   let5 = 'e';
  248.   }
  249.   else if(guessword == "video") {
  250.   lettercount = 5;
  251.   blankcount = 5;
  252.   blank1 = '_';
  253.   blank2 = '_';
  254.   blank3 = '_';
  255.   blank4 = '_';
  256.   blank5 = '_';
  257.   let1 = 'v';
  258.   let2 = 'i';
  259.   let3 = 'd';
  260.   let4 = 'e';
  261.   let5 = 'o';
  262.   }
  263.   else if(guessword == "room") {
  264.   lettercount = 4;
  265.   blankcount = 4;
  266.   blank1 = '_';
  267.   blank2 = '_';
  268.   blank3 = '_';
  269.   blank4 = '_';
  270.   blank5 = '_';
  271.   let1 = 'r';
  272.   let2 = 'o';
  273.   let3 = 'o';
  274.   let4 = 'm';
  275.   }
  276.   return;
  277.  }
  278.  
  279. // GET WORD 2
  280.  
  281.  void getword2(void) {
  282.  
  283.   string words[10] = {
  284.             "octopus",
  285.             "monitor",
  286.             "manual",
  287.             "speakers",
  288.             "television",
  289.             "glasses",
  290.             "poster",
  291.             "mountain",
  292.             "keyboard",
  293.             "elephant"};
  294.  
  295.     int j;
  296.     const int N = 10;
  297.  
  298.     srand( (unsigned)time( NULL ) );
  299.  
  300.     for (j = 0; j < 10; j++) {
  301.         rand();
  302.     }
  303.  
  304.   j = (int) N * rand() / (RAND_MAX + 1.0);
  305.  
  306.   guessword = words[j];
  307.  
  308.  
  309.   if(guessword == "octopus") {
  310.   lettercount = 7;
  311.   blankcount = 7;
  312.   blank1 = '_';
  313.   blank2 = '_';
  314.   blank3 = '_';
  315.   blank4 = '_';
  316.   blank5 = '_';
  317.   blank6 = '_';
  318.   blank7 = '_';
  319.   let1 = 'o';
  320.   let2 = 'c';
  321.   let3 = 't';
  322.   let4 = 'o';
  323.   let5 = 'p';
  324.   let6 = 'u';
  325.   let7 = 's';
  326.   }
  327.   else if(guessword == "monitor") {
  328.   lettercount = 7;
  329.   blankcount = 7;
  330.   blank1 = '_';
  331.   blank2 = '_';
  332.   blank3 = '_';
  333.   blank4 = '_';
  334.   blank5 = '_';
  335.   blank6 = '_';
  336.   blank7 = '_';
  337.   let1 = 'm';
  338.   let2 = 'o';
  339.   let3 = 'n';
  340.   let4 = 'i';
  341.   let5 = 't';
  342.   let6 = 'o';
  343.   let7 = 'r';
  344.   }
  345.   else if(guessword == "manual") {
  346.   lettercount = 6;
  347.   blankcount = 6;
  348.   blank1 = '_';
  349.   blank2 = '_';
  350.   blank3 = '_';
  351.   blank4 = '_';
  352.   blank5 = '_';
  353.   blank6 = '_';
  354.   let1 = 'm';
  355.   let2 = 'a';
  356.   let3 = 'n';
  357.   let4 = 'u';
  358.   let5 = 'a';
  359.   let6 = 'l';
  360.   }
  361.   else if(guessword == "speakers") {
  362.   lettercount = 8;
  363.   blankcount = 8;
  364.   blank1 = '_';
  365.   blank2 = '_';
  366.   blank3 = '_';
  367.   blank4 = '_';
  368.   blank5 = '_';
  369.   blank6 = '_';
  370.   blank7 = '_';
  371.   blank8 = '_';
  372.   let1 = 's';
  373.   let2 = 'p';
  374.   let3 = 'e';
  375.   let4 = 'a';
  376.   let5 = 'k';
  377.   let6 = 'e';
  378.   let7 = 'r';
  379.   let8 = 's';
  380.   }
  381.   else if(guessword == "television") {
  382.   lettercount = 10;
  383.   blankcount = 10;
  384.   blank1 = '_';
  385.   blank2 = '_';
  386.   blank3 = '_';
  387.   blank4 = '_';
  388.   blank5 = '_';
  389.   blank1 = '_';
  390.   blank2 = '_';
  391.   blank3 = '_';
  392.   blank4 = '_';
  393.   blank5 = '_';
  394.   let1 = 't';
  395.   let2 = 'e';
  396.   let3 = 'l';
  397.   let4 = 'e';
  398.   let5 = 'v';
  399.   let6 = 'i';
  400.   let7 = 's';
  401.   let8 = 'i';
  402.   let9 = 'o';
  403.   let10 = 'n';
  404.   }
  405.   else if(guessword == "glasses") {
  406.   lettercount = 7;
  407.   blankcount = 7;
  408.   blank1 = '_';
  409.   blank2 = '_';
  410.   blank3 = '_';
  411.   blank4 = '_';
  412.   blank5 = '_';
  413.   blank6 = '_';
  414.   blank7 = '_';
  415.   let1 = 'g';
  416.   let2 = 'l';
  417.   let3 = 'a';
  418.   let4 = 's';
  419.   let5 = 's';
  420.   let6 = 'e';
  421.   let7 = 's';
  422.   }
  423.   else if(guessword == "poster") {
  424.   lettercount = 6;
  425.   blankcount = 6;
  426.   blank1 = '_';
  427.   blank2 = '_';
  428.   blank3 = '_';
  429.   blank4 = '_';
  430.   blank5 = '_';
  431.   blank6 = '_';
  432.   let1 = 'p';
  433.   let2 = 'o';
  434.   let3 = 's';
  435.   let4 = 't';
  436.   let5 = 'e';
  437.   let6 = 'r';
  438.   }
  439.   else if(guessword == "mountain") {
  440.   lettercount = 8;
  441.   blankcount = 8;
  442.   blank1 = '_';
  443.   blank2 = '_';
  444.   blank3 = '_';
  445.   blank4 = '_';
  446.   blank5 = '_';
  447.   blank6 = '_';
  448.   blank7 = '_';
  449.   blank8 = '_';
  450.   let1 = 'm';
  451.   let2 = 'o';
  452.   let3 = 'u';
  453.   let4 = 'n';
  454.   let5 = 't';
  455.   let6 = 'a';
  456.   let7 = 'i';
  457.   let8 = 'n';
  458.   }
  459.   else if(guessword == "keyboard") {
  460.   lettercount = 8;
  461.   blankcount = 8;
  462.   blank1 = '_';
  463.   blank2 = '_';
  464.   blank3 = '_';
  465.   blank4 = '_';
  466.   blank5 = '_';
  467.   blank6 = '_';
  468.   blank7 = '_';
  469.   blank8 = '_';
  470.   let1 = 'k';
  471.   let2 = 'e';
  472.   let3 = 'y';
  473.   let4 = 'b';
  474.   let5 = 'o';
  475.   let6 = 'a';
  476.   let7 = 'r';
  477.   let8 = 'd';
  478.   }
  479.   else if(guessword == "elephant") {
  480.   lettercount = 8;
  481.   blankcount = 8;
  482.   blank1 = '_';
  483.   blank2 = '_';
  484.   blank3 = '_';
  485.   blank4 = '_';
  486.   blank5 = '_';
  487.   blank6 = '_';
  488.   blank7 = '_';
  489.   blank8 = '_';
  490.   let1 = 'e';
  491.   let2 = 'l';
  492.   let3 = 'e';
  493.   let4 = 'p';
  494.   let5 = 'h';
  495.   let6 = 'a';
  496.   let7 = 'n';
  497.   let8 = 't';
  498.   }
  499.   return;
  500.  }
  501.  
  502.  // GET WORD 3
  503.  
  504.   void getword3(void) {
  505.  
  506.   string words[10] = {
  507.             "onomonopia",
  508.             "regardless",
  509.             "irresponsible",
  510.             "cornerstone",
  511.             "mummification",
  512.             "deathshroud",
  513.             "destruction",
  514.             "mountainous",
  515.             "compactdisc",
  516.             "deconstruct"};
  517.  
  518.     int j;
  519.     const int N = 10;
  520.  
  521.     srand( (unsigned)time( NULL ) );
  522.  
  523.     for (j = 0; j < 10; j++) {
  524.         rand();
  525.     }
  526.  
  527.   j = (int) N * rand() / (RAND_MAX + 1.0);
  528.  
  529.   guessword = words[j];
  530.  
  531.  
  532.   if(guessword == "onomonopia") {
  533.   lettercount = 10;
  534.   blankcount = 10;
  535.   blank1 = '_';
  536.   blank2 = '_';
  537.   blank3 = '_';
  538.   blank4 = '_';
  539.   blank5 = '_';
  540.   blank6 = '_';
  541.   blank7 = '_';
  542.   blank8 = '_';
  543.   blank9 = '_';
  544.   blank10 = '_';
  545.   let1 = 'o';
  546.   let2 = 'n';
  547.   let3 = 'o';
  548.   let4 = 'm';
  549.   let5 = 'o';
  550.   let6 = 'n';
  551.   let7 = 'o';
  552.   let8 = 'p';
  553.   let9 = 'i';
  554.   let10 = 'a';
  555.   }
  556.   else if(guessword == "regardless") {
  557.     lettercount = 10;
  558.   blankcount = 10;
  559.   blank1 = '_';
  560.   blank2 = '_';
  561.   blank3 = '_';
  562.   blank4 = '_';
  563.   blank5 = '_';
  564.   blank6 = '_';
  565.   blank7 = '_';
  566.   blank8 = '_';
  567.   blank9 = '_';
  568.   blank10 = '_';
  569.   let1 = 'o';
  570.   let2 = 'c';
  571.   let3 = 't';
  572.   let4 = 'o';
  573.   let5 = 'p';
  574.   let6 = 'u';
  575.   let7 = 's';
  576.   let8 = 'p';
  577.   let9 = 'u';
  578.   let10 = 's';
  579.   }
  580.   else if(guessword == "irresponsible") {
  581.   lettercount = 13;
  582.   blankcount = 13;
  583.   blank1 = '_';
  584.   blank2 = '_';
  585.   blank3 = '_';
  586.   blank4 = '_';
  587.   blank5 = '_';
  588.   blank6 = '_';
  589.   blank7 = '_';
  590.   blank8 = '_';
  591.   blank9 = '_';
  592.   blank10 = '_';
  593.   blank11 = '_';
  594.   blank12 = '_';
  595.   blank13 = '_';
  596.   let1 = 'i';
  597.   let2 = 'r';
  598.   let3 = 'r';
  599.   let4 = 'e';
  600.   let5 = 's';
  601.   let6 = 'p';
  602.   let7 = 'o';
  603.   let8 = 'n';
  604.   let9 = 's';
  605.   let10 = 'i';
  606.   let11 = 'b';
  607.   let12 = 'l';
  608.   let13 = 'e';
  609.   }
  610.   else if(guessword == "cornerstone") {
  611.   lettercount = 11;
  612.   blankcount = 11;
  613.   blank1 = '_';
  614.   blank2 = '_';
  615.   blank3 = '_';
  616.   blank4 = '_';
  617.   blank5 = '_';
  618.   blank6 = '_';
  619.   blank7 = '_';
  620.   blank8 = '_';
  621.   blank9 = '_';
  622.   blank10 = '_';
  623.   blank11 = '_';
  624.   let1 = 'c';
  625.   let2 = 'o';
  626.   let3 = 'r';
  627.   let4 = 'n';
  628.   let5 = 'e';
  629.   let6 = 'r';
  630.   let7 = 's';
  631.   let8 = 't';
  632.   let9 = 'o';
  633.   let10 = 'n';
  634.   let11 = 'e';
  635.   }
  636.   else if(guessword == "mummification") {
  637.   lettercount = 13;
  638.   blankcount = 13;
  639.   blank1 = '_';
  640.   blank2 = '_';
  641.   blank3 = '_';
  642.   blank4 = '_';
  643.   blank5 = '_';
  644.   blank6 = '_';
  645.   blank7 = '_';
  646.   blank8 = '_';
  647.   blank9 = '_';
  648.   blank10 = '_';
  649.   blank11 = '_';
  650.   blank12 = '_';
  651.   blank13 = '_';
  652.   let1 = 'm';
  653.   let2 = 'u';
  654.   let3 = 'm';
  655.   let4 = 'm';
  656.   let5 = 'i';
  657.   let6 = 'f';
  658.   let7 = 'i';
  659.   let8 = 'c';
  660.   let9 = 'a';
  661.   let10 = 't';
  662.   let11 = 'i';
  663.   let12 = 'o';
  664.   let13 = 'n';
  665.   }
  666.   else if(guessword == "deathshroud") {
  667.   lettercount = 11;
  668.   blankcount = 11;
  669.   blank1 = '_';
  670.   blank2 = '_';
  671.   blank3 = '_';
  672.   blank4 = '_';
  673.   blank5 = '_';
  674.   blank6 = '_';
  675.   blank7 = '_';
  676.   blank8 = '_';
  677.   blank9 = '_';
  678.   blank10 = '_';
  679.   blank11 = '_';
  680.   let1 = 'd';
  681.   let2 = 'e';
  682.   let3 = 'a';
  683.   let4 = 't';
  684.   let5 = 'h';
  685.   let6 = 's';
  686.   let7 = 'h';
  687.   let8 = 'r';
  688.   let9 = 'o';
  689.   let10 = 'u';
  690.   let11 = 'd';
  691.   }
  692.   else if(guessword == "destruction") {
  693.   lettercount = 11;
  694.   blankcount = 11;
  695.   blank1 = '_';
  696.   blank2 = '_';
  697.   blank3 = '_';
  698.   blank4 = '_';
  699.   blank5 = '_';
  700.   blank6 = '_';
  701.   blank7 = '_';
  702.   blank8 = '_';
  703.   blank9 = '_';
  704.   blank10 = '_';
  705.   blank11 = '_';
  706.   let1 = 'd';
  707.   let2 = 'e';
  708.   let3 = 's';
  709.   let4 = 't';
  710.   let5 = 'r';
  711.   let6 = 'u';
  712.   let7 = 'c';
  713.   let8 = 't';
  714.   let9 = 'i';
  715.   let10 = 'o';
  716.   let11 = 'n';
  717.   }
  718.   else if(guessword == "mountainous") {
  719.   lettercount = 11;
  720.   blankcount = 11;
  721.   blank1 = '_';
  722.   blank2 = '_';
  723.   blank3 = '_';
  724.   blank4 = '_';
  725.   blank5 = '_';
  726.   blank6 = '_';
  727.   blank7 = '_';
  728.   blank8 = '_';
  729.   blank9 = '_';
  730.   blank10 = '_';
  731.   blank11 = '_';
  732.   let1 = 'm';
  733.   let2 = 'o';
  734.   let3 = 'u';
  735.   let4 = 'n';
  736.   let5 = 't';
  737.   let6 = 'a';
  738.   let7 = 'i';
  739.   let8 = 'n';
  740.   let9 = 'o';
  741.   let10 = 'u';
  742.   let11 = 's';
  743.   }
  744.   else if(guessword == "compactdisc") {
  745.   lettercount = 11;
  746.   blankcount = 11;
  747.   blank1 = '_';
  748.   blank2 = '_';
  749.   blank3 = '_';
  750.   blank4 = '_';
  751.   blank5 = '_';
  752.   blank6 = '_';
  753.   blank7 = '_';
  754.   blank8 = '_';
  755.   blank9 = '_';
  756.   blank10 = '_';
  757.   blank11 = '_';
  758.   let1 = 'c';
  759.   let2 = 'o';
  760.   let3 = 'm';
  761.   let4 = 'p';
  762.   let5 = 'a';
  763.   let6 = 'c';
  764.   let7 = 't';
  765.   let8 = 'd';
  766.   let9 = 'i';
  767.   let10 = 's';
  768.   let11 = 'c';
  769.   }
  770.   else if(guessword == "deconstruct") {
  771.   lettercount = 11;
  772.   blankcount = 11;
  773.   blank1 = '_';
  774.   blank2 = '_';
  775.   blank3 = '_';
  776.   blank4 = '_';
  777.   blank5 = '_';
  778.   blank6 = '_';
  779.   blank7 = '_';
  780.   blank8 = '_';
  781.   blank9 = '_';
  782.   blank10 = '_';
  783.   blank11 = '_';
  784.   let1 = 'd';
  785.   let2 = 'e';
  786.   let3 = 'c';
  787.   let4 = 'o';
  788.   let5 = 'n';
  789.   let6 = 's';
  790.   let7 = 't';
  791.   let8 = 'r';
  792.   let9 = 'u';
  793.   let10 = 'c';
  794.   let11 = 't';
  795.   }
  796.   return;
  797.  }
  798.  
  799. // CHECK LETTER
  800.  
  801. void checkletter(void) {
  802.  
  803.   if(guess == let1 && let1done != 1) {
  804.   cout << "Correct! " << guess << " is the first letter.\n";
  805.   blank1 = guess;
  806.   lettercount--;
  807.   let1done = 1;
  808.   }
  809.   else if(guess == let2 && let2done != 1) {
  810.   cout << "Correct! " << guess << " is the second letter.\n";
  811.   blank2 = guess;
  812.   lettercount--;
  813.   let2done = 1;
  814.   }
  815.   else if(guess == let3 && let3done != 1) {
  816.   cout << "Correct! " << guess << " is the third letter.\n";
  817.   blank3 = guess;
  818.   lettercount--;
  819.   let3done = 1;
  820.   }
  821.   else if(guess == let4 && let4done != 1) {
  822.   cout << "Correct! " << guess << " is the fourth letter.\n";
  823.   blank4 = guess;
  824.   lettercount--;
  825.   let4done = 1;
  826.   }
  827.   else if(guess == let5 && let5done != 1) {
  828.   cout << "Correct! " << guess << " is the fifth letter.\n";
  829.   blank5 = guess;
  830.   lettercount--;
  831.   let5done = 1;
  832.   }
  833.   else {
  834.   cout << "Wrong! " << guess << " is not one of the letters.\n";
  835.   hangercount++;
  836.   }
  837.   easy();
  838.   }
  839.  
  840. // CHECK LETTER 2
  841.  
  842.   void checkletter2(void) {
  843.  
  844.   if(guess == let1 && let1done != 1) {
  845.   cout << "Correct! " << guess << " is the first letter.\n";
  846.   blank1 = guess;
  847.   lettercount--;
  848.   let1done = 1;
  849.   }
  850.   else if(guess == let2 && let2done != 1) {
  851.   cout << "Correct! " << guess << " is the second letter.\n";
  852.   blank2 = guess;
  853.   lettercount--;
  854.   let2done = 1;
  855.   }
  856.   else if(guess == let3 && let3done != 1) {
  857.   cout << "Correct! " << guess << " is the third letter.\n";
  858.   blank3 = guess;
  859.   lettercount--;
  860.   let3done = 1;
  861.   }
  862.   else if(guess == let4 && let4done != 1) {
  863.   cout << "Correct! " << guess << " is the fourth letter.\n";
  864.   blank4 = guess;
  865.   lettercount--;
  866.   let4done = 1;
  867.   }
  868.   else if(guess == let5 && let5done != 1) {
  869.   cout << "Correct! " << guess << " is the fifth letter.\n";
  870.   blank5 = guess;
  871.   lettercount--;
  872.   let5done = 1;
  873.   }
  874.     else if(guess == let6 && let6done != 1) {
  875.   cout << "Correct! " << guess << " is the fifth letter.\n";
  876.   blank6 = guess;
  877.   lettercount--;
  878.   let6done = 1;
  879.   }
  880.     else if(guess == let7 && let7done != 1) {
  881.   cout << "Correct! " << guess << " is the fifth letter.\n";
  882.   blank7 = guess;
  883.   lettercount--;
  884.   let7done = 1;
  885.   }
  886.     else if(guess == let8 && let8done != 1) {
  887.   cout << "Correct! " << guess << " is the fifth letter.\n";
  888.   blank8 = guess;
  889.   lettercount--;
  890.   let8done = 1;
  891.   }
  892.     else if(guess == let9 && let9done != 1) {
  893.   cout << "Correct! " << guess << " is the fifth letter.\n";
  894.   blank9 = guess;
  895.   lettercount--;
  896.   let9done = 1;
  897.   }
  898.     else if(guess == let10 && let10done != 1) {
  899.   cout << "Correct! " << guess << " is the fifth letter.\n";
  900.   blank10 = guess;
  901.   lettercount--;
  902.   let10done = 1;
  903.   }
  904.   else {
  905.   cout << "Wrong! " << guess << " is not one of the letters.\n";
  906.   hangercount++;
  907.   }
  908.   normal();
  909.   }
  910.  
  911. // CHECK LETTER 3
  912.  
  913.     void checkletter3(void) {
  914.  
  915.   if(guess == let1 && let1done != 1) {
  916.   cout << "Correct! " << guess << " is the first letter.\n";
  917.   blank1 = guess;
  918.   lettercount--;
  919.   let1done = 1;
  920.   }
  921.   else if(guess == let2 && let2done != 1) {
  922.   cout << "Correct! " << guess << " is the second letter.\n";
  923.   blank2 = guess;
  924.   lettercount--;
  925.   let2done = 1;
  926.   }
  927.   else if(guess == let3 && let3done != 1) {
  928.   cout << "Correct! " << guess << " is the third letter.\n";
  929.   blank3 = guess;
  930.   lettercount--;
  931.   let3done = 1;
  932.   }
  933.   else if(guess == let4 && let4done != 1) {
  934.   cout << "Correct! " << guess << " is the fourth letter.\n";
  935.   blank4 = guess;
  936.   lettercount--;
  937.   let4done = 1;
  938.   }
  939.   else if(guess == let5 && let5done != 1) {
  940.   cout << "Correct! " << guess << " is the fifth letter.\n";
  941.   blank5 = guess;
  942.   lettercount--;
  943.   let5done = 1;
  944.   }
  945.     else if(guess == let6 && let6done != 1) {
  946.   cout << "Correct! " << guess << " is the fifth letter.\n";
  947.   blank6 = guess;
  948.   lettercount--;
  949.   let6done = 1;
  950.   }
  951.     else if(guess == let7 && let7done != 1) {
  952.   cout << "Correct! " << guess << " is the fifth letter.\n";
  953.   blank7 = guess;
  954.   lettercount--;
  955.   let7done = 1;
  956.   }
  957.     else if(guess == let8 && let8done != 1) {
  958.   cout << "Correct! " << guess << " is the fifth letter.\n";
  959.   blank8 = guess;
  960.   lettercount--;
  961.   let8done = 1;
  962.   }
  963.     else if(guess == let9 && let9done != 1) {
  964.   cout << "Correct! " << guess << " is the fifth letter.\n";
  965.   blank9 = guess;
  966.   lettercount--;
  967.   let9done = 1;
  968.   }
  969.     else if(guess == let10 && let10done != 1) {
  970.   cout << "Correct! " << guess << " is the fifth letter.\n";
  971.   blank10 = guess;
  972.   lettercount--;
  973.   let10done = 1;
  974.   }
  975.       else if(guess == let11 && let11done != 1) {
  976.   cout << "Correct! " << guess << " is the fifth letter.\n";
  977.   blank11 = guess;
  978.   lettercount--;
  979.   let10done = 1;
  980.   }
  981.       else if(guess == let12 && let12done != 1) {
  982.   cout << "Correct! " << guess << " is the fifth letter.\n";
  983.   blank12 = guess;
  984.   lettercount--;
  985.   let10done = 1;
  986.   }
  987.       else if(guess == let13 && let13done != 1) {
  988.   cout << "Correct! " << guess << " is the fifth letter.\n";
  989.   blank13 = guess;
  990.   lettercount--;
  991.   let10done = 1;
  992.   }
  993.   else {
  994.   cout << "Wrong! " << guess << " is not one of the letters.\n";
  995.   hangercount++;
  996.   }
  997.   hard();
  998.   }
  999.  
  1000. // EASY
  1001.  
  1002. void easy(void)
  1003.   {
  1004.   if(worddone == 0) {
  1005.   getword();
  1006.   worddone = 1;}
  1007.   if(lettercount == 0) {
  1008.   cout << "\nYou've won! The word was " << guessword << ".\n\n";
  1009.   cout << "\nWould you like to play again? (Y)es or (N)o? ";
  1010.   cin >> again;
  1011.   if(again == 'y') {
  1012.   runagain = true;
  1013.   }
  1014.   return;
  1015.   }
  1016.   if(hangercount == 0) {
  1017.   cout << hang1 << endl;
  1018.   cout << hang2 << endl;
  1019.   cout << hang3 << endl;
  1020.   cout << hang4 << endl;
  1021.   cout << hang5 << endl;
  1022.   cout << hang6 << endl;
  1023.   }
  1024.   if(hangercount == 1) {
  1025.   cout << hang11 << endl;
  1026.   cout << hang12 << endl;
  1027.   cout << hang13 << endl;
  1028.   cout << hang14 << endl;
  1029.   cout << hang15 << endl;
  1030.   cout << hang16 << endl;
  1031.   }
  1032.   if(hangercount == 2) {
  1033.   cout << hang21 << endl;
  1034.   cout << hang22 << endl;
  1035.   cout << hang23 << endl;
  1036.   cout << hang24 << endl;
  1037.   cout << hang25 << endl;
  1038.   cout << hang26 << endl;
  1039.   }
  1040.   if(hangercount == 3) {
  1041.   cout << hang31 << endl;
  1042.   cout << hang32 << endl;
  1043.   cout << hang33 << endl;
  1044.   cout << hang34 << endl;
  1045.   cout << hang35 << endl;
  1046.   cout << hang36 << endl;
  1047.   }
  1048.   if(hangercount == 4) {
  1049.   cout << hang41 << endl;
  1050.   cout << hang42 << endl;
  1051.   cout << hang43 << endl;
  1052.   cout << hang44 << endl;
  1053.   cout << hang45 << endl;
  1054.   cout << hang46 << endl;
  1055.   }
  1056.   if(hangercount == 5) {
  1057.   cout << hang51 << endl;
  1058.   cout << hang52 << endl;
  1059.   cout << hang53 << endl;
  1060.   cout << hang54 << endl;
  1061.   cout << hang55 << endl;
  1062.   cout << hang56 << endl;
  1063.   }
  1064.   if(hangercount == 6) {
  1065.   cout << hang61 << endl;
  1066.   cout << hang62 << endl;
  1067.   cout << hang63 << endl;
  1068.   cout << hang64 << endl;
  1069.   cout << hang65 << endl;
  1070.   cout << hang66 << endl;
  1071.   cout << "\nYou've lost! Poor guy.\n";
  1072.   cout << "\nThe word was " << guessword << ".\n";
  1073.   cout << "\nWould you like to play again? (Y)es or (N)o? ";
  1074.   cin >> again;
  1075.   if(again == 'y') {
  1076.   runagain = true;
  1077.   return;
  1078.   }
  1079.   return;
  1080.   }
  1081.   cout << "\n" << endl;
  1082.   if(blankcount == 4) {
  1083.   cout << blank1 << " " << blank2 << " " << blank3 << " " << blank4 << endl;
  1084.   }
  1085.   if(blankcount == 5) {
  1086.   cout << blank1 << " " << blank2 << " " << blank3 << " " << blank4 << " " << blank5 << endl;
  1087.   }
  1088.   cout << "\nEnter your guess: ";
  1089.   cin >> guess;
  1090.   cout << "\nYou guessed the letter " << guess << ".\n";
  1091.   checkletter();
  1092.   }
  1093.  
  1094.  
  1095. // NORMAL
  1096.  
  1097. void normal(void)
  1098.   {
  1099.   if(worddone == 0) {
  1100.   getword2();
  1101.   worddone = 1;}
  1102.   if(lettercount == 0) {
  1103.   cout << "\nYou've won! The word was " << guessword << ".\n\n";
  1104.   cout << "\nWould you like to play again? (Y)es or (N)o? ";
  1105.   cin >> again;
  1106.   if(again == 'y') {
  1107.   runagain = true;
  1108.   return;
  1109.   }
  1110.   return;
  1111.   }
  1112.   if(hangercount == 0) {
  1113.   cout << hang1 << endl;
  1114.   cout << hang2 << endl;
  1115.   cout << hang3 << endl;
  1116.   cout << hang4 << endl;
  1117.   cout << hang5 << endl;
  1118.   cout << hang6 << endl;
  1119.   }
  1120.   if(hangercount == 1) {
  1121.   cout << hang11 << endl;
  1122.   cout << hang12 << endl;
  1123.   cout << hang13 << endl;
  1124.   cout << hang14 << endl;
  1125.   cout << hang15 << endl;
  1126.   cout << hang16 << endl;
  1127.   }
  1128.   if(hangercount == 2) {
  1129.   cout << hang21 << endl;
  1130.   cout << hang22 << endl;
  1131.   cout << hang23 << endl;
  1132.   cout << hang24 << endl;
  1133.   cout << hang25 << endl;
  1134.   cout << hang26 << endl;
  1135.   }
  1136.   if(hangercount == 3) {
  1137.   cout << hang31 << endl;
  1138.   cout << hang32 << endl;
  1139.   cout << hang33 << endl;
  1140.   cout << hang34 << endl;
  1141.   cout << hang35 << endl;
  1142.   cout << hang36 << endl;
  1143.   }
  1144.   if(hangercount == 4) {
  1145.   cout << hang41 << endl;
  1146.   cout << hang42 << endl;
  1147.   cout << hang43 << endl;
  1148.   cout << hang44 << endl;
  1149.   cout << hang45 << endl;
  1150.   cout << hang46 << endl;
  1151.   }
  1152.   if(hangercount == 5) {
  1153.   cout << hang51 << endl;
  1154.   cout << hang52 << endl;
  1155.   cout << hang53 << endl;
  1156.   cout << hang54 << endl;
  1157.   cout << hang55 << endl;
  1158.   cout << hang56 << endl;
  1159.   }
  1160.   if(hangercount == 6) {
  1161.   cout << hang61 << endl;
  1162.   cout << hang62 << endl;
  1163.   cout << hang63 << endl;
  1164.   cout << hang64 << endl;
  1165.   cout << hang65 << endl;
  1166.   cout << hang66 << endl;
  1167.   cout << "\nYou've lost! Poor guy.\n";
  1168.   cout << "\nThe word was " << guessword << ".\n";
  1169.   cout << "\nWould you like to play again? (Y)es or (N)o? ";
  1170.   cin >> again;
  1171.   if(again == 'y') {
  1172.   runagain = true;
  1173.   }
  1174.   return;
  1175.   }
  1176.   cout << "\n" << endl;
  1177.   if(blankcount == 6) {
  1178.   cout << blank1 << " " << blank2 << " " << blank3 << " " << blank4 << " " << blank5 << " " << blank6 << endl;
  1179.   }
  1180.   if(blankcount == 7) {
  1181.   cout << blank1 << " " << blank2 << " " << blank3 << " " << blank4 << " " << blank5 << " " << blank6 << " " << blank7 << endl;
  1182.   }
  1183.   if(blankcount == 8) {
  1184.   cout << blank1 << " " << blank2 << " " << blank3 << " " << blank4 << " " << blank5 << " " << blank6 << " " << blank7 << " " << blank8 << endl;
  1185.   }
  1186.   if(blankcount == 10) {
  1187.   cout << blank1 << " " << blank2 << " " << blank3 << " " << blank4 << " " << blank5 << " " << blank6 << " " << blank7 << " " << blank8 << " " << blank9 << " " << blank10 << endl;
  1188.   }
  1189.   cout << "\nEnter your guess: ";
  1190.   cin >> guess;
  1191.   cout << "\nYou guessed the letter " << guess << ".\n";
  1192.   checkletter2();
  1193.   }
  1194.  
  1195. // HARD  
  1196.  
  1197. void hard(void)
  1198.   {
  1199.   if(worddone == 0) {
  1200.   getword3();
  1201.   worddone = 1;}
  1202.   if(lettercount == 0) {
  1203.   cout << "\nYou've won! The word was " << guessword << ".\n\n";
  1204.   cout << "\nWould you like to play again? (Y)es or (N)o? ";
  1205.   cin >> again;
  1206.   if(again == 'y') {
  1207.   runagain = true;
  1208.   return;
  1209.   }
  1210.   return;
  1211.   }
  1212.   if(hangercount == 0) {
  1213.   cout << hang1 << endl;
  1214.   cout << hang2 << endl;
  1215.   cout << hang3 << endl;
  1216.   cout << hang4 << endl;
  1217.   cout << hang5 << endl;
  1218.   cout << hang6 << endl;
  1219.   }
  1220.   if(hangercount == 1) {
  1221.   cout << hang11 << endl;
  1222.   cout << hang12 << endl;
  1223.   cout << hang13 << endl;
  1224.   cout << hang14 << endl;
  1225.   cout << hang15 << endl;
  1226.   cout << hang16 << endl;
  1227.   }
  1228.   if(hangercount == 2) {
  1229.   cout << hang21 << endl;
  1230.   cout << hang22 << endl;
  1231.   cout << hang23 << endl;
  1232.   cout << hang24 << endl;
  1233.   cout << hang25 << endl;
  1234.   cout << hang26 << endl;
  1235.   }
  1236.   if(hangercount == 3) {
  1237.   cout << hang31 << endl;
  1238.   cout << hang32 << endl;
  1239.   cout << hang33 << endl;
  1240.   cout << hang34 << endl;
  1241.   cout << hang35 << endl;
  1242.   cout << hang36 << endl;
  1243.   }
  1244.   if(hangercount == 4) {
  1245.   cout << hang41 << endl;
  1246.   cout << hang42 << endl;
  1247.   cout << hang43 << endl;
  1248.   cout << hang44 << endl;
  1249.   cout << hang45 << endl;
  1250.   cout << hang46 << endl;
  1251.   }
  1252.   if(hangercount == 5) {
  1253.   cout << hang51 << endl;
  1254.   cout << hang52 << endl;
  1255.   cout << hang53 << endl;
  1256.   cout << hang54 << endl;
  1257.   cout << hang55 << endl;
  1258.   cout << hang56 << endl;
  1259.   }
  1260.   if(hangercount == 6) {
  1261.   cout << hang61 << endl;
  1262.   cout << hang62 << endl;
  1263.   cout << hang63 << endl;
  1264.   cout << hang64 << endl;
  1265.   cout << hang65 << endl;
  1266.   cout << hang66 << endl;
  1267.   cout << "\nYou've lost! Poor guy.\n";
  1268.   cout << "\nThe word was " << guessword << ".\n";
  1269.   cout << "\nWould you like to play again? (Y)es or (N)o? ";
  1270.   cin >> again;
  1271.   if(again == 'y') {
  1272.   runagain = true;
  1273.   }
  1274.   return;
  1275.   }
  1276.   cout << "\n" << endl;
  1277.   if(blankcount == 10) {
  1278.   cout << blank1 << " " << blank2 << " " << blank3 << " " << blank4 << " " << blank5 << " " << blank6 << " " << blank7 << " " << blank8 << " " << blank9 << " " << blank10 << endl;
  1279.   }
  1280.   if(blankcount == 11) {
  1281.   cout << blank1 << " " << blank2 << " " << blank3 << " " << blank4 << " " << blank5 << " " << blank6 << " " << blank7 << " " << blank8 << " " << blank9 << " " << blank10 << " " << blank11 << endl;
  1282.   }
  1283.   if(blankcount == 13) {
  1284.   cout << blank1 << " " << blank2 << " " << blank3 << " " << blank4 << " " << blank5 << " " << blank6 << " " << blank7 << " " << blank8 << " " << blank9 << " " << blank10 << " " << blank11 << " " << blank12 << " " << blank13 << endl;
  1285.   }
  1286.   cout << "\nEnter your guess: ";
  1287.   cin >> guess;
  1288.   cout << "\nYou guessed the letter " << guess << ".\n";
  1289.   checkletter3();
  1290.   }
  1291.  
  1292. // MAIN
  1293.  
  1294. int main(void)
  1295.    {
  1296.    runagain = false;
  1297.    blankcount = 0;
  1298.    worddone = 0;
  1299.    lettercount = 20;
  1300.    hangercount = 0;
  1301.    let1 = '0';
  1302.    let2 = '0';
  1303.    let3 = '0';
  1304.    let4 = '0';
  1305.    let5 = '0';
  1306.    let6 = '0';
  1307.    let7 = '0';
  1308.    let8 = '0';
  1309.    let9 = '0';
  1310.    let10 = '0';
  1311.    let11 = '0';
  1312.    let12 = '0';
  1313.    let12 = '0';
  1314.    let1done = 0;
  1315.    let2done = 0;
  1316.    let3done = 0;
  1317.    let4done = 0;
  1318.    let5done = 0;
  1319.    let6done = 0;
  1320.    let7done = 0;
  1321.    let8done = 0;
  1322.    let9done = 0;
  1323.    let10done = 0;
  1324.    let11done = 0;
  1325.    let12done = 0;
  1326.    let13done = 0;
  1327.    blank1 = '_';
  1328.    blank2 = '_';
  1329.    blank3 = '_';
  1330.    blank4 = '_';
  1331.    blank5 = '_';
  1332.    blank6 = '_';
  1333.    blank7 = '_';
  1334.    blank8 = '_';
  1335.    blank9 = '_';
  1336.    blank10 = '_';
  1337.    blank11 = '_';
  1338.    blank12 = '_';
  1339.    blank13 = '_';
  1340.    int mode = 0;
  1341.    unsigned int option = 0;
  1342.    
  1343.         cout << "\nWelcome to Hangman v1.0\n\nPlease select an option.\n\n1. Start a game of hangman.\n2. Exit Hangman.\n\nEnter selection: ";
  1344.         cin >> option;
  1345.         cout << "\n";
  1346.    
  1347.         if(option == 1) {
  1348.                 cout << "Please select a difficulty level.\n1. Easy\n2. Normal\n3. Hard\n4. About difficulty levels\n\nEnter selection: ";
  1349.                 cin >> mode;
  1350.         }
  1351.        
  1352.         if(option == 2) {
  1353.         return 0;
  1354.         }
  1355.        
  1356.         if(mode == 1) {
  1357.         cout << "\nEasy mode selected.\n\n";
  1358.         easy();
  1359.         }
  1360.        
  1361.         else if(mode == 2) {
  1362.         cout << "\nNormal mode selected.\n\n";
  1363.         normal();
  1364.         }
  1365.        
  1366.         else if(mode == 3) {
  1367.         cout << "\nHard mode selected.\n\n";
  1368.         hard();
  1369.         }
  1370.        
  1371.         else if(mode == 4) {
  1372.         cout << "\nEasy mode contains smaller words.\nNormal mode contains medium words.\nHard mode contains long words.\n\n";
  1373.         cout << "Please select a difficulty level.\n1. Easy\n2. Normal\n3. Hard\n\nEnter selection: ";
  1374.         cin >> mode;   
  1375.     }
  1376.    
  1377.     if(option != 1 || option != 2 || option != 0) {
  1378.     cout << "This is not a valid option. Please select 1 or 2.\n";
  1379.     main();
  1380.     }    
  1381.    
  1382.    if(runagain == true) {
  1383.    main();
  1384.    }
  1385.    return 0;
  1386.    }
clone this paste RAW Paste Data