石头剪刀布 哪里出错了?运行不了
  • 板块灌水区
  • 楼主xuchuze
  • 当前回复12
  • 已保存回复13
  • 发布时间2025/1/16 16:10
  • 上次更新2025/1/16 19:20:52
查看原帖
石头剪刀布 哪里出错了?运行不了
1277711
xuchuze楼主2025/1/16 16:10

如上题所述

#include<bits/stdc++.h>
using namespace std;
int randnum(int n){
	srand((unsigned int)time(NULL));
	n=rand()%3+1;
	return n;
} 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	while(1){
		cout<<"game start\n";
		cout<<"1=剪刀\n";
		cout<<"2=石头\n";
		cout<<"3=布\n";
		int num1;
		cin>>num1;
		int num2=randnum(num2);
		if(num1=num2) cout<<"draw!\n";
		else if(num1>num2){
			if(num1=2) cout<<"win\n";
			else if(num2=1){
				cout<<"game over\n";
			}
		}
		else{
			if(num1=2) cout<<"game over\n";
			else if(num2=1){
				cout<<"win\n";
			}
		}
		cout<<"again?1=true 0=false\n";
		bool m;
		cin>>m;
		if(m==0) return 0;
		system("cls");
	}
	return 0;
} 
2025/1/16 16:10
加载中...