#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int getComputerChoice() {
int choices[] = {1, 2, 3}; // 1代表石头,2代表剪刀,3代表布
int randomIndex
= rand() % 3;
return choices[randomIndex];
}
int getPlayerChoice() {
int choice;
printf("请输入你的选择(1-石头,2-剪刀,3-布):");
while (choice < 1 || choice > 3) {
printf("输入无效,请重新输入(1-石头,2-剪刀,3-布):");
}
return choice;
}
void determineWinner(int playerChoice, int computerChoice) {
if (playerChoice == computerChoice) {
} else if ((playerChoice == 1 && computerChoice == 2) ||
(playerChoice == 2 && computerChoice == 3) ||
(playerChoice == 3 && computerChoice == 1)) {
} else {
}
}
int main() {
int playerChoice, computerChoice;
do {
playerChoice = getPlayerChoice();
computerChoice = getComputerChoice();
switch (computerChoice) {
case 1:
break;
case 2:
break;
case 3:
break;
}
determineWinner(playerChoice, computerChoice);
int playAgain;
} while (playAgain == 1);
return 0;
}