石头剪刀布c++游戏(求赞(自创))
2026-10-11 15:38:28
发布于:浙江
#include<bits/stdc++.h>
#include"windows.h"
using namespace std;
int main(){
cout << "请输入你要玩的局数";
int n;
cin >> n;
int p1score = 0;
int p2score = 0;
for(int i = 1; i <= n; i++){
char p1;
cout << "请输入P1出的东西(石头 = s, 剪刀 = j, 布 = b)";
cin >> p1;
system("cls");
char p2;
cout << "请输入P2出的东西(石头 = s, 剪刀 = j, 布 = b)";
cin >> p2;
system("cls");
if(p1 == 's'){
if(p2 == 'j'){
p1score++;
cout << "P1 win" << endl;
}else if(p2 == 'b'){
p2score++;
cout << "P2 win" << endl;
}else{
cout << "NO win" << endl;
}
}
if(p1 == 'j'){
if(p2 == 'b'){
p1score++;
cout << "P1 win" << endl;
}else if(p2 == 's'){
p2score++;
cout << "P2 win" << endl;
}else{
cout << "NO win" << endl;
}
}
if(p1 == 'b'){
if(p2 == 's'){
p1score++;
cout << "P1 win" << endl;
}else if(p2 == 'j'){
p2score++;
cout << "P2 win" << endl;
}else{
cout << "NO win" << endl;
}
}
cout << p1score << " " << p2score << endl;
Sleep(1000);
}
if(p1score > p2score){
cout << "P1 win!";
}
if(p1score < p2score){
cout << "P2 win!";
}
if(p1score == p2score){
cout << "NO win";
}
return 0;
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
这里空空如也
















有帮助,赞一个