I am new to C++ and wrote this code. It is a rock, paper and scissors game. But the problem is that when for example computer and player both got 'rock' the computer says 1 - 0 or 0 - 1. Does anyone know how to fix that?
I also want to add a scoreboard when I make more rounds, but I don't know how to do that in this code. Can anyone help me?
thanks!
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
int random ((rand() % 3) + 1);
string steen;
string papier;
int main(int argc, char **argv)
{
srand(time(0));
cout << "Welkom bij steen papier schaar: druk op enter om verder te gaan.";
cin.get();
cout <<"You are playing against the computer. your choices are 'rock' 'paper' and 'scissors'. good luck!\n\n";
cout << "Round 1\n";
cout << "rock paper or scissors: ";
cin >> steen;
if((rand() % 3) + 1 == 1) { cout << "computer: steen"; }
else if ((rand() % 3) + 1 == 2) { cout << "computer: papier"; }
else if ((rand() % 3) + 1 == 3) { cout << "computer: schaar";}
if (random == 1 and steen == "steen") { cout << "\n1 - 1\n"; }
else if (random == 2 and steen == "papier") { cout << "\n1 - 1\n"; }
else if (random == 3 and steen == "schaar") { cout << "\n1 - 1\n"; }
else if (random == 1 and steen == "papier") { cout << "\n 1 - 0 \n"; }
else if (random == 1 and steen == "schaar") { cout << "\n0 - 1\n"; }
else if (random == 2 and steen == "steen") { cout << "\n0 - 1\n"; }
else if (random == 2 and steen == "schaar") { cout << "\n1 - 0\n"; }
else if (random == 3 and steen == "steen") { cout << "\n1 - 0\n"; }
else if (random == 3 and steen == "papier") { cout << "\n0 - 1\n"; }
else { cout << "syntax error\n\n" ; return 0; }
return 0;
}