Задача по C++!!!

Написать игру "УГАДАЙ ЧИСЛО(10 попыток)"циклами while и do while.

Ответы

Ответ дал: personanonim22
1

Ответ:

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

 

/////////////////////////////////////////////////////////////////

int main()

{

  int n;

  int x;

  int count = 0;

 

  srand(time(0));

  n = rand()%10 + 1;

 

  cout << "Igra 'ugadai chislo'" << endl  

       << "Computer zadumal chislo ot 1 do 10" << endl

       << "Ugadaite ego za 5 popitok." << endl;

 

  do  

  {

      cout << "\nVvedite chislo i nashmite 'enter'\n\t-> ";

      cin >> x;

      if (x == n) cout << "Ura! Vi ugadali!";

      count++;  

  } while (x!=n && count<5);

 

 

  return 0;

}

Объяснение:


personanonim22: выбери самый лучший буду очень рад
Вас заинтересует