Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- using namespace std;
- int cast() {
- int a = rand() % 6 + 1;
- int b = rand() % 6 + 1;
- cout << a << ", " << b << endl;
- return a + b;
- }
- void game() {
- srand(time(0));
- int computer_glasses = 0;
- int person_glasses = 0;
- int first = rand() % 2;
- if (first == 0) {
- cout << "Первым бросает компьютер" << endl;
- }
- else {
- cout << "Первым бросает человек" << endl;
- }
- for (int i = 1; i <= 10; i++) {
- if (i % 2 != 0 && first == 0 || i % 2 == 0 && first == 1) {
- cout << "Бросок компьютера: ";
- computer_glasses += cast();
- }
- else {
- cout << "Бросок человека: ";
- person_glasses += cast();
- }
- }
- cout << "Компьютер: " << computer_glasses << " " << "Человек: " << person_glasses << endl;
- if (computer_glasses > person_glasses) {
- cout << "Победил компьютер!" << endl;
- }
- else if (computer_glasses < person_glasses) {
- cout << "Победил человек!" << endl;
- }
- else {
- cout << "Ничья!" << endl;
- }
- }
- int main() {
- setlocale(LC_ALL, "ru");
- game();
- }
Advertisement
Add Comment
Please, Sign In to add comment