rock paper scissors

Üdvözlöm, Ön a rock paper scissors szó jelentését keresi. A DICTIOUS-ban nem csak a rock paper scissors szó összes szótári jelentését megtalálod, hanem megismerheted az etimológiáját, a jellemzőit és azt is, hogyan kell a rock paper scissors szót egyes és többes számban mondani. Minden, amit a rock paper scissors szóról tudni kell, itt található. A rock paper scissors szó meghatározása segít abban, hogy pontosabban és helyesebben fogalmazz, amikor beszélsz vagy írsz. Arock paper scissors és más szavak definíciójának ismerete gazdagítja a szókincsedet, és több és jobb nyelvi forráshoz juttat.

Főnév

rock paper scissors (tsz. rock paper scissorses)

  1. (informatika) kő-papír-olló
#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

string getComputerChoice() {
    int randNum = rand() % 3; // 0 = rock, 1 = paper, 2 = scissors
    if (randNum == 0) return "rock";
    else if (randNum == 1) return "paper";
    else return "scissors";
}

string getUserChoice() {
    string choice;
    cout << "Enter your choice (rock, paper, or scissors): ";
    cin >> choice;
    return choice;
}

string determineWinner(string user, string computer) {
    if (user == computer) return "It's a draw!";
    if ((user == "rock" && computer == "scissors") ||
        (user == "scissors" && computer == "paper") ||
        (user == "paper" && computer == "rock")) {
        return "You win!";
    }
    return "Computer wins!";
}

int main() {
    srand(time(0)); // Initialize random seed

    string userChoice = getUserChoice();
    string computerChoice = getComputerChoice();

    cout << "Computer chose: " << computerChoice << endl;
    cout << determineWinner(userChoice, computerChoice) << endl;

    return 0;
}