Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Лаба 2 здача 3
- // Используя оператор do..while: угадать число от 1 до 1000 не более чем за 10 попыток (вводится предполагаемое число, программа "отвечает": искомое больше/меньше или отгадано)
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- srand(time(0));
- int x = int(rand()) % 1000;
- //cout << x;
- for (int i = 0; i < 10; i++) {
- int now;
- cout << "You have " << 10 - i << " attempts \n";
- cin >> now;
- if (now == x) {
- cout << "You Win!";
- return 0;
- }
- if (now > x) {
- cout << "Less \n";
- }
- if (now < x) {
- cout << "More \n";
- }
- }
- cout << "You Lose!";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement