How to make rock paper scissor game using C++ ?

Rock / Paper / Scissors [Game] [C++]

void main () {
int a[3][3];
int b = 3, c;
char play[8];
randomize();
a[0][0] = 0;
a[0][1] = -1;
a[0][2] = 1;
a[1][0] = 1;
a[1][1] = 0;
a[1][2] = -1;
a[2][0] = -1;
a[2][1] = 1;
a[2][2] = 0;

b = randomize(b);
cout<<“Rock / Paper / Scissors – By Y-Gaming n n”;
cin<<play;

if (strcmpi(play,”rock”)==0) {
cout<<“You: Rock n”;
c = a[0][b];
}
if (strcmpi(play,”paper”)==0) {
cout<<“You: Paper n”;
c = a[1][b];
}
if (strcmpi(play,”scissors”)==0) {
cout<<“You: Scissors n”;
c = a[2][b];
}

if (b==0)
cout<<“Computer: Rock n”;
if (b==1)
cout<<“Computer: Paper n”;
if (b==2)
cout<<“Computer: Scissors n”;

if (c==1)
cout<<“You Win!”;
else if (c==0)
cout<<“It’s a Tie!”;
else if (c==-1)
cout<<“You Lose!”;
getch();
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Optimization WordPress Plugins & Solutions by W3 EDGE
%d bloggers like this: