游戏
  • 板块灌水区
  • 楼主kong_chen
  • 当前回复6
  • 已保存回复6
  • 发布时间2024/11/9 20:10
  • 上次更新2024/11/9 22:07:07
查看原帖
游戏
1054549
kong_chen楼主2024/11/9 20:10
#include<bits/stdc++.h>
using namespace std;
int give,give2;
int main(){
	cout<<"这是一个石头剪刀布的游戏"<<endl;
	cout<<"1是石头,2是剪刀,3是布"<<endl;
	srand(time(0));
	cout<<"好了,游戏开始"; 
	for(;;){
		cout<<"请输入你的";
		cin>>give;
		give2=rand()%(3-1+1)+1;
		if(give2==1){
			if(give==1){
				cout<<"平";
			}
			else if(give==2){
				cout<<"输"; 
			}
			else{
				cout<<"赢";
			}
		} 
		else if(give2==2){
			if(give==1){
				cout<<"赢";
			}
			else if(give==2){
				cout<<"平"; 
			}
			else{
				cout<<"输";
			}
		} 
		else{
			if(give==1){
				cout<<"输";
			}
			else if(give==2){
				cout<<"赢"; 
			}
			else{
				cout<<"平";
			}		
		}
	}
	return 0;
} 
2024/11/9 20:10
加载中...