Untitled
unknown
plain_text
a year ago
1.8 kB
8
Indexable
#include <iostream>
using namespace std;
int show()
{
while (true)
{
cout << "This is a rock scissors paper game\n";
cout << "1. rock 2. scissors 3. paper\n";
int random = rand() % 4 + 1;
int select = 0;
cin >> select;
switch (select)
{
case 1:
{
if (random == 1)
{
cout << "random output is rock " << endl;
cout << "Tie\n";
break;
}
else if (random == 2)
{
cout << "random output is scissors " << endl;
cout << "You win\n";
system("pause");
system("cls");
return 0;
}
else if (random == 3)
{
cout << "random output is paper" << endl;
cout << "You lose\n";
break;
}
}
case 2:
{
if (random == 1)
{
cout << "random output is rock " << endl;
cout << "You lose\n";
break;
}
else if (random == 2)
{
cout << "random output is scissors " << endl;
cout << "Tie\n";
break;
}
else if (random == 3)
{
cout << "random output is paper" << endl;
cout << "You Win\n";
system("pause");
system("cls");
return 0;
}
}
case 3:
{
if (random == 1)
{
cout << "random output is rock " << endl;
cout << "You Win\n";
system("pause");
system("cls");
return 0;
}
else if (random == 2)
{
cout << "random output is scissors " << endl;
cout << "You Lose\n";
break;
}
else if (random == 3)
{
cout << "random output is paper" << endl;
cout << "Tie\n";
break;
}
}
default:
{
cout << "Key in between 1-3\n";
}
}
}
}
int main()
{
srand((unsigned int)time(NULL));
show();
system("pause");
}Editor is loading...
Leave a Comment