Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. #include "StdAfx.h"
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <random>
  5. #include <time.h>
  6. #include <cstring>
  7.  
  8. using namespace std;
  9.  
  10. int main(){
  11. setlocale(LC_ALL, "Rus");
  12. system("color 0A");
  13. int input;
  14. int number;
  15. int attempt = 0;
  16. int answer = 0;
  17. cout << "Я загадал число от 1 до 25, угадай его!" << endl;
  18. cout << "У тебя есть 10 попыток!" << endl;
  19. do{
  20. srand(time(NULL));
  21. number = rand() % 25 + 1;
  22. do{
  23. answer = 1;
  24. if (attempt != 10){
  25. cin >> input;
  26. if (input == number){
  27. cout << "Верно! Правильное число " << number << endl;
  28. cout << "Хочешь сыграть еще? (1 - да, 2 - выход)" << endl;
  29. do{
  30. cin >> answer;
  31. if (answer == 1){
  32. attempt = 6-1;
  33. cout << "Давай сыграем еще! У тебя есть "<< attempt << " попыток!" << endl;
  34. }
  35. else if (answer == 2){
  36. return 0;
  37. }
  38. else {
  39. cout << "Неправильное число! Введите 1 для продолжение или 2 для выхода!" << endl;
  40. }
  41. } while (answer != 1 || answer != 2);
  42. }
  43. else if (input < number){
  44. cout << "Побольше!" << endl;
  45. }
  46. else if (input > number){
  47. cout << "Поменьше!" << endl;
  48. }
  49. attempt++;
  50. }
  51. else {
  52. cout << "Твои попытки закончились! Ты проиграл, правильное число: " << number << endl;
  53. _getch();
  54. return 0;
  55. }
  56. } while (input == number);
  57. } while (answer = 1);
  58. _getch();
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement