Advertisement
Guest User

all code

a guest
Sep 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5.  
  6. /*int RandNum(int firstNum, int secondNum, int thirdNum) {
  7. int initialRandInt = rand() % 10;
  8.  
  9. firstNum = initialRandInt;
  10. secondNum = initialRandInt;
  11. thirdNum = initialRandInt;
  12.  
  13. while ( secondNum == firstNum ) {
  14. secondNum = rand() % 10;
  15. }
  16. while ( thirdNum == firstNum || thirdNum == secondNum ) {
  17. thirdNum = rand() % 10;
  18. }
  19. return firstNum, secondNum, thirdNum;
  20. }*/
  21.  
  22.  
  23. int main()
  24. {
  25. // Display game information and rules //
  26. cout << "Program: 2 MasterMind" << endl;
  27. cout << "The program selects 3 distinct random digits 0..9." << endl;
  28. cout << "On each turn you guess 3 digits. Program indicates how many are correct." << endl;
  29. cout << "You have 10 moves to guess the number. "
  30. << "Good luck!" << endl << endl;
  31.  
  32. // setting the 3 digits with 's' or randomizing with 'r'
  33. cout << "Press 's' to set the three digits, or 'r' to randomize them:" << endl;
  34. char userInput = ' ';
  35. cin >> userInput;
  36.  
  37. // setting the value of each number
  38. int firstNum;
  39. int secondNum;
  40. int thirdNum;
  41.  
  42. if ( userInput == 's') {
  43. cin >> firstNum >> secondNum >> thirdNum;
  44. }
  45. else if ( userInput == 'r') {
  46. int initialRandInt = rand() % 10;
  47.  
  48. firstNum = initialRandInt;
  49. secondNum = initialRandInt;
  50. thirdNum = initialRandInt;
  51. }
  52. while ( secondNum == firstNum ) {
  53. secondNum = rand() % 10;
  54. }
  55. while ( thirdNum == firstNum || thirdNum == secondNum ) {
  56. thirdNum = rand() % 10;
  57. }
  58.  
  59. cout << "Values to guess are: " << firstNum << secondNum << thirdNum;
  60. cout << endl << endl << "Exiting...";
  61.  
  62.  
  63.  
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement