#include<iostream>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<stdlib.h>
using namespace std;
double Count_com=0; //??????????
double Count_you=0; //?????????
int stone = 1?? cloth = 2?? scissors = 3; //????????е???????
/////////////////????//////////////////////
int randget(int start?? int end);
double getDoubleRand(int start?? int end);
void gameing();
void start1();
void start2();
void start3();
void tell(int com?? int you);
/////////////////????randget///////////////
int randget(int start?? int end)
{
return rand() % (end - start + 1) + start; //??start??end?????????;
}
/////////////////????getDoubleRand/////////
double getDoubleRand(int start?? int end)
{
return rand() % (end - start + 1) + start;
}
////////////////???????????////////////////
void start1()
{
srand((unsigned int)time(NULL));
char x;
int com = 0?? you = 0;
cout << "       Z:??X:???C:??  ???:" << endl;
while (1)
{
if (_kbhit())   //_kbhit()?ж?????м??????
{
x = _getch();
if ((x == 'Z' || x == 'z'))  you = 1;
if ((x == 'X' || x == 'x'))  you = 3;
if ((x == 'C' || x == 'c'))  you = 2;
while (_kbhit())
_getch();
com = randget(1?? 3);
tell(com??you);
}
}
}
////////////////?????????///////////////
void start2()
{
cout << "???????????????" << endl;
system("pause");
srand((unsigned int)time(NULL));
int coin = 0;
long double rec = 0?? times = 0?? rec2 = 0;
for (;;)
{
Sleep(50);  //???y???????.
times += 1;
coin = randget(0?? 1); //??????????
if (coin == 1)     //????ж?
{
rec++;
cout << "???? ???漸??:" << rec / times << "%" << endl;
}
if (coin == 0)
{
rec2++;
cout << "???? ???漸??:" << rec2 / times << "%" << endl;
}
}
}
////////////////????π?????////////////
void start3()
{
srand((unsigned int)time(NULL));
cout << "?????????π????????κμ????.(???????)" << endl;
double x = 0?? y = 0; //????????x??y??????
double pi = 0?? times = 0?? distance = 0?? init = 0;
for (;;)
{
Sleep(50);
times += 1;
x = getDoubleRand(0?? 2);
y = getDoubleRand(0?? 2);
distance = (x - 1)*(x - 1) + (y - 1)*(y - 1);
if (distance <= 1)
{
init += 1;
cout << "??????" << times << "?μ???π?????π?????????:" << 4 * ( init / times )/ 1 << endl;
}
}
}
/////////////??????///////////////////
void tell(int com?? int you)
{
double rate?? temp;
temp = Count_you + Count_com;
rate = Count_you / temp * 100;
if (com == you)
{
cout << "?????!" << "****************.........................??????:" << rate << "%" << endl;
}
if ((com == 1) && (you == 2))
{
cout << "?????!****" << "????>>>??****??>>>??" << "...............??????:" << rate << "%" << endl;
Count_you++;
}
if ((com == 1) && (you == 3))
{
cout << "??????!****" << "????>>>??****??>>>???" << ".............??????:" << rate << "%" << endl;
Count_com++;
}
if ((com == 2) && (you == 1))
{
cout << "??????!****" << "????>>>??  ****??>>>??" << ".............??????:" << rate << "%" << endl;
Count_com++;
}
if ((com == 2) && (you == 3))
{
cout << "?????!****" << "????>>>??  ****??>>>???" << ".............??????:" << rate << "%" << endl;
Count_you++;
}
if ((com == 3) && (you == 1))
{
cout << "?????!****" << "????>>>???****??>>>??" << ".............??????:" << rate << "%" << endl;
Count_you++;
}
if ((com == 3) && (you == 2))
{
cout << "??????!****" << "????>>>???****??>>>?? " << "..............??????:" << rate << "%" << endl;
Count_com++;
}
}
/////////////??????//////////////////////
int main()
{
int choice=0;
again:  cout << "________________________???????_____________________" << endl;
cout << "1.???????." << endl;
cout << "2.?????." << endl;
cout << "3.π?????." << endl;
cout << "_____________________________________________________" << endl;
cin >> choice;
switch (choice)
{
case 1:start1();
case 2:start2();
case 3:start3();
[cpp] view plaincopy??CODE?????????????????????
default:goto again;
}
system("pause");