Skip to content

Commit

Permalink
Update Backgammon.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
valya1 committed May 2, 2016
1 parent fa8b5f2 commit f5be0a8
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions Backgammon/Backgammon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ void init()

void show_field()
{
int pos = 11; // ãåíåðàöèÿ ñ 11 ÿ÷åéêè
int pos = 11; // ãåíåðàöèÿ ñ 11 ÿ÷åéêè
cout << " 11 10 9 8 7 6 5 4 3 2 1 0" << endl;
cout << "---------------------------------------------------------------" << endl;
for (int i = 0; i < 15; i++) // ïåðâûå 15 ñòðîê
for (int i = 0; i < 15; i++) // ïåðâûå 15 ñòðîê
{
pos = 11;
cout << "| ";
Expand All @@ -43,7 +43,7 @@ void show_field()
}
cout << "|" << endl;
}
for (int i = 15; i > 0; i--) // ïîñëåäíèå 15 ñòðîê
for (int i = 15; i > 0; i--) // ïîñëåäíèå 15 ñòðîê
{
pos = 12;
cout << "| ";
Expand All @@ -61,7 +61,6 @@ void show_field()
cout << "|" << endl;
}


cout << "---------------------------------------------------------------" << endl;
cout << " 12 13 14 15 16 17 18 19 20 21 22 23" << endl;
for (int i = 0; i < 3; i++)
Expand All @@ -73,39 +72,39 @@ void throw_dice()
srand(time(0));
dice1 = rand() % 6 + 1;
dice2 = rand() % 6 + 1;
cout << " Íà ïåðâîì êóáèêå âûïàëî: " << dice1 << endl;
cout << " Íà âòîðîì êóáèêå âûïàëî: " << dice2 << endl;
cout << " Íà ïåðâîì êóáèêå âûïàëî: " << dice1 << endl;
cout << " Íà âòîðîì êóáèêå âûïàëî: " << dice2 << endl;
}

void turn(int player)
{
vecint dices;
int pos, points;
bool flag = 0; // ïðèçíàê òîãî, ÷òî õîä âåðåí
bool flag = 0; // ïðèçíàê òîãî, ÷òî õîä âåðåí
throw_dice();
dices.push_back(dice1);
dices.push_back(dice2);
if (dice1 == dice2) // äóáëü
if (dice1 == dice2) // äóáëü
{
cout << "Âàì âûïàë äóáëü!!!" << endl << endl;;
cout << "Âàì âûïàë äóáëü!!!" << endl << endl;;
dices.push_back(dice1);
dices.push_back(dice2);
}
while (!dices.empty())
{
cout << "Ââåäèòå íîìåð ÿ÷åéêè, îòêóäà ïåðåñòàâëÿòü: ";
cout << "Ââåäèòå íîìåð ÿ÷åéêè, îòêóäà ïåðåñòàâëÿòü: ";
cin >> pos;
while (chip[pos] != p[player - 1])
{
cout << "Õâàòèò õîäèòü ÷óæèìè ôèøêàìè!" << endl;
cout << "Õâàòèò õîäèòü ÷óæèìè ôèøêàìè!" << endl;
cin >> pos;
}
cout << "Êîëè÷åñòâî î÷êîâ: ";
cout << "Êîëè÷åñòâî î÷êîâ: ";
cin >> points;
for (int i = 0; i < dices.size(); i++)
if (points == dices[i])
{
dices.erase(dices.begin() + i); // óäàëÿåì êóáèê èç ìàññèâà êóáèêîâ
dices.erase(dices.begin() + i); // óäàëÿåì êóáèê èç ìàññèâà êóáèêîâ
flag = true;
break;
}
Expand All @@ -119,7 +118,7 @@ void turn(int player)
show_field();

if (!dices.empty())
cout << "Ó âàñ îñòàëèñü ñëåäóþùèå õîäû: " << endl;
cout << "Ó âàñ îñòàëèñü ñëåäóþùèå õîäû: " << endl;
for (int i = 0; i < dices.size(); i++)
cout << dices[i] << " ";
cout << endl;
Expand Down

0 comments on commit f5be0a8

Please sign in to comment.