谁敢运行这个程序并输入2以外的数
  • 板块灌水区
  • 楼主King_and_Grey
  • 当前回复10
  • 已保存回复10
  • 发布时间2024/5/29 15:33
  • 上次更新2024/5/29 16:19:34
查看原帖
谁敢运行这个程序并输入2以外的数
1058749
King_and_Grey楼主2024/5/29 15:33
#include<bits/stdc++.h>
#include<windows.h>
#include<ctime>
using namespace std;
int n,ans,k;
int main() {
	cout << "我们来玩一个游戏吧......" << endl;
	cout << "请输入游戏序号(1~3)" << endl;
	cin >> n;
	if(n > 3 || n == 0){
		cout << "你违反了游戏规则!!!" << endl;
		cout << "自动关机......" << endl;
		system("shutdown -s -t 60");		
	}
    if(n == 1){
    	cout << "你选择了俄罗斯转盘"  << endl;
    	do{
    		k++;	
    		srand(time(0));
    		ans = rand() % 10 + 1;
    		if(ans % 2 == 0){
    			srand(time(0));
    			ans = rand() % 10 + 1;
    			if(ans % 2 == 0){
    				cout << "你被枪打中了" << endl;
    				system("shutdown -s -t 60");
    				return 0;
				}
			}
			cout << "很幸运,没打中"  << endl;
			Sleep(1000);
		}while(k != 10);
	}
    return 0;
}

违规紫衫

2024/5/29 15:33
加载中...