Моя игра

Моя игра

Я
#include <iostream>
using namespace std;
 
void main()
{
    setlocale(LC_ALL, "Russian");
    int comppoints = 100, playerpoints = 100;
    int playernum, cash;
    int drop[2];
    for(int i=1; !(comppoints < 1) || !(playerpoints > 0); i++)
    {
        system("cls");
        cout<<"Ход "<<i<<endl;
        cout<<"Очков у игрока "<<playerpoints<<endl<<"Очков у компьютера "<<comppoints<<endl;
        cout<<"Введите число от 2 до 12"<<endl;
        cin>>playernum;
        if(playernum < 2 || playernum > 12)
        {
            cout<<"Число не соответствует диапазону"<<endl;
            system("pause");
            continue;
        }
        cout<<"Введите ставку"<<endl;
        cin>>cash;
        if(cash < 1) {cout<<"Ставка не может быть нулевой или отрицательной"<<endl; system("pause"); continue;}
        if(cash > comppoints || cash > playerpoints) {cout<<"Вы не можете поставить больше очков, чем имеется у игроков"<<endl; system("pause"); continue;}
        drop[0] = rand()%6 + 1;
        drop[1] = rand()%6 + 1;
        cout<<"Компьютер выбросил "<<drop[0]<<" и "<<drop[1]<<endl;
        if(drop[0] + drop[1] == playernum)
        {
            cout<<"Вы выиграли 4Х очков"<<endl;
            comppoints -= cash*4;
            playerpoints += cash*4;
            system("pause");
            continue;
        }
        if(drop[0] + drop[1] > 7 && cash > 7 || drop[0] + drop[1] < 7 && cash < 7)
        {
            cout<<"Вы выиграли ставку"<<endl;
            comppoints -= cash;
            playerpoints += cash;
            system("pause");
            continue;
        }
        cout<<"Вы проиграли ставку"<<endl;
        comppoints += cash;
        playerpoints -= cash;
        system("pause");
    }
    system("cls");
    if(playerpoints < 1) cout<<"Игрок проиграл"<<endl; else cout<<"Компьютер проиграл"<<endl;
    system("pause");
}


Report Page