Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Лаба 2 здача 3
  2. // Используя оператор do..while: угадать число от 1 до 1000 не более чем за 10 попыток (вводится предполагаемое число, программа "отвечает": искомое больше/меньше или отгадано)
  3.  
  4. #include <bits/stdc++.h>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. srand(time(0));
  10. int x = int(rand()) % 1000;
  11. //cout << x;
  12. for (int i = 0; i < 10; i++) {
  13. int now;
  14. cout << "You have " << 10 - i << " attempts \n";
  15. cin >> now;
  16. if (now == x) {
  17. cout << "You Win!";
  18. return 0;
  19. }
  20. if (now > x) {
  21. cout << "Less \n";
  22. }
  23. if (now < x) {
  24. cout << "More \n";
  25. }
  26. }
  27. cout << "You Lose!";
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement