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();
}


About Akshat Jagga

Hey there! I am a proficient (Well, I think so) tech reviewer,Application developer with good knowledge in Swift,Android and Java. I also have a little knowledge of C,C++,html and php. Other than making awesome things, I am interested in roaming around the town and I love to eat pizza!

Leave a Reply