为何玩家输入只能是剪刀(自己做的,违规紫衫
  • 板块灌水区
  • 楼主inkfox_exe
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/12/6 21:49
  • 上次更新2023/12/7 03:40:47
查看原帖
为何玩家输入只能是剪刀(自己做的,违规紫衫
1055698
inkfox_exe楼主2023/12/6 21:49
#include<bits/stdc++.h>
#include<conio.h>
#include<windows.h>
using namespace std;
int x=100,g=2;
int x1=10,g1=1;
int x2=20,g2=2;
int x3=50,g3=5;
int b=1000,b1=10;
void print(int op,int c){
	if(op==1){
		cout<<"Rock!"<<"	";
	}
	else if(op==2){
		cout<<"Scissors!"<<"	";
	}
	else{
		cout<<"Paper!"<<"	";
	}
	
	if(c==1){
		cout<<"Rock!";
	}
	else if(c==2){
		cout<<"Scissors!";
	}
	else{
		cout<<"Paper!";
	}
}

void wl(int op,int c){
	if(op==1){
		if(c==1){
			system("color");
			cout<<endl<<"Tie!";
			Sleep(1000);
			system("cls");
		}
		else if(c==2){
			system("color");
			cout<<endl<<"Win!";
			Sleep(1000);
			system("cls");
		}
		else{
			system("color");
			cout<<endl<<"Lose!";
			Sleep(1000);
			system("cls");
		}
	}
	
	else if(op==2){
		if(c==2){
			system("color");
			cout<<endl<<"Tie!";
			Sleep(1000);
			system("cls");
		}
		else if(c==3){
			system("color");
			cout<<endl<<"Win!";
			Sleep(1000);
			system("cls");
		}
		else{
			system("color");
			cout<<endl<<"Lose!";
			Sleep(1000);
			system("cls");
		}
	}
	
	else{
		if(c==3){
			system("color");
			cout<<endl<<"Tie!";
			Sleep(1000);
			system("cls");
		}
		else if(c==1){
			system("color");
			cout<<endl<<"Win!";
			Sleep(1000);
			system("cls");
		}
		else{
			system("color");
			cout<<endl<<"Lose!";
			Sleep(1000);
			system("cls");
		}	
	}
}
int main(){
	srand(time(0));
	int op,f=1,c;
	while(f){
		op=getch();
		c=rand()%2+1;
		print(op,c);//output
		wl(op,c);//w or l
	}
	return 0;
}
2023/12/6 21:49
加载中...