相信大家小时候都玩过剪刀石头布的游戏,现在用C++来实现一下。
还有,就是小编刚学C++不久,可能有一些错误,请各位大佬多多指教
思路:
通过时间作为种子,生成一个随机数,然后取其各位作为判断石头剪刀布的标准
代码:
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<Windows.h>
#include<conio.h>
#include<cstdio>
using namespace std;
void wrong_form()
{
cout<<"emmmmm ";
Sleep(500);
cout<<"Maybe your form is wrong,check it.";
Sleep(1000);
system("cls");
}
void srp()
{
//初始化
int ran=0,guess=0;
string computer;
srand(time(0));
ran=rand()%10;
switch(ran)
{
case 0:
case 1:
case 2:
computer="S";
break;
case 3:
case 4:
case 5:
computer="