#include <iostream>
#include <cstdlib>
using namespace std;
int main(void){
srand(time(NULL));
int c = rand()%3;
string x[3] = {"剪刀","石頭","布"};
int user = 0;
cout << "輸入(0=剪刀 1=石頭 2=布)" << endl;
cin >> user;
if(user == c){
cout << "您出:" << x[user] << ",電腦出:" << x[c] << endl;
cout << "平手!\n";
}else if(user > c || (user == 0 && c == 2)){
cout << "您出:" << x[user] << ",電腦出:" << x[c] << endl;
cout << "您贏了!\n";
}else if(user < c || (user == 2 && c == 0)){
cout << "您出:" << x[user] << ",電腦出:" << x[c] << endl;
cout << "您輸了!\n";
}
system("pause");
return 0;
} |