C++:自创小游戏

欢迎来玩,每次都有不一样的结果。

长达142行。

cpp 复制代码
#include<bits/stdc++.h>
#include<windows.h>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
int main(){
	int n;
	cout<<"输1~10,越小越好,不告诉你有什么用,当然也可以输入密码5963"<<endl; 
	cin>>n;
	Sleep(3000);
	cout<<"$_$"<<endl;
	Sleep(2000);
	cout<<"^_^"<<endl;
	Sleep(2000);
	cout<<"#_#"<<endl;
	Sleep(2000);
	cout<<"^/\^"<<endl;
	Sleep(2000);
	cout<<"\^_^/"<<endl;
	Sleep(2000);
	cout<<"<'_'>"<<endl;
	Sleep(2000);
	cout<<"@------@"<<endl;
	Sleep(2000);
	cout<<"(@_@)"<<endl;
	Sleep(2000);
	cout<<"/^o^/"<<endl;
	Sleep(2000);
	cout<<"|0<>0|"<<endl;
	Sleep(2000);
	cout<<"你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?"<<endl;
	cout<<"你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?"<<endl;
	cout<<"你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?"<<endl;
	cout<<"你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?"<<endl;
	cout<<"你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?"<<endl;
	cout<<"你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?你喜欢哪个?"<<endl;
	Sleep(8000);
	cout<<"(○`(●●)′○)ノ 像xxx"<<endl;
	Sleep(5000);
	cout<<"不要生气了,看看这个呢?"<<endl;
	Sleep(3000);
	cout<<"( ̄(●●) ̄) "<<endl;
	Sleep(3000);
	cout<<"(~ ̄(OO) ̄)ブ"<<endl;
	Sleep(3000);
	cout<<"( ̄▽ ̄)~*       O(∩_∩)O哈哈~"<<endl; 
	cout<<"  **"<<endl;
	cout<<" ****"<<endl;
	cout<<"******"<<endl;
	cout<<" ****"<<endl;
	Sleep(5000);
	cout<<"   *"<<endl;
	cout<<"  *  "<<endl;
	cout<<"   *"<<endl;
	cout<<"  *"<<endl;
	Sleep(5000);
	cout<<"你刚才输入的数:"<<n<<endl;
	if(n>=5&&n<=10){
		cout<<"你是猪"; 
	}
	if(n<5&&n>=1){
		cout<<"你是狗"; 
	} 
	int a=0;
	if(n==0){
		cout<<"幸运儿,你准备好了吗?"<<endl;
		Sleep(3000);
		cout<<"   *   "<<endl;
		cout<<" **** **                    *" <<endl;
		cout<<"**********   万箭齐发! ******xxx"<<endl;  
		cout<<"  * * **                    *"<<endl;
		cout<<"  * *"<<endl;
		cin>>a; 
		cout<<"触发宇宙爆炸!";
		Sleep(1000); 
		cout<<"宇宙即将爆炸!";
		Sleep(300);
		if(a==0){
			Sleep(400);
			cout<<"宇宙已经爆炸,没有机会,你已死亡!"; 
		}
		else if(a>0&&a<=10){
			Sleep(1001);
			cout<<"机会很低!";
			Sleep(200);
			srand((unsigned)time(NULL)); 
			cout<<"逃跑分钟:"<<random(1,6); 
			}
		else{
			Sleep(1250);
			cout<<"机会很大!"; 
			Sleep(300);
			srand((unsigned)time(NULL));
			cout<<"逃跑分钟:";
			Sleep(500);
			cout<<" "<<random(10,20);
			cout<<" "<<"只要不作死,就能活。"; 
		}
	} 
	if(n==5963){
		cout<<"猜数游戏(1-100)"<<endl;
		srand(time(NULL));
		int key=rand()%100+1;
		for(int i=1;i<=7;i++)
		{
			int x;
			cout<<"请输入一个数字:";
			cin>>x;
			if(x<key)
			{
				cout<<"小了"<<endl;
			} 
			if(x>key)
			{
				cout<<"大了"<<endl;
			} 
	    	if(x==key)
			{
				cout<<"恭喜您,猜对啦!"<<endl;
				Sleep(1500);
		    	cout<<"进入下一个游戏。";
				    int w;
					cout<<"请输入一个1~5:"; 
					cin>>w;
					switch(w) 
					{
					case 1:cout<<"没有中奖"<<endl;break;
					case 2:cout<<"中奖了"<<endl;break; 
					case 3:cout<<"中奖了"<<endl;break; 
					case 4:cout<<"没有中奖."<<endl;break; 
					case 5:cout<<"没有中奖."<<endl;break; 
				    default:cout<<"无事发生。"<<endl;break;
				    Sleep(500);
				    cout<<"Game Over!!!O(∩_∩)O哈哈~";
					return 0; 
				} 
			} 
		}
		cout<<"7次机会已用完,很遗憾,未猜对!"<<endl;
		cout<<"正确数字是:"<<key<<endl;
	} 
	return 0;
}

创作不易,希望大家关注三连!!!

相关推荐
крон2 小时前
【Auto.js例程】华为备忘录导出到其他手机
开发语言·javascript·智能手机
zh_xuan3 小时前
c++ 单例模式
开发语言·c++·单例模式
老胖闲聊3 小时前
Python Copilot【代码辅助工具】 简介
开发语言·python·copilot
Blossom.1183 小时前
使用Python和Scikit-Learn实现机器学习模型调优
开发语言·人工智能·python·深度学习·目标检测·机器学习·scikit-learn
曹勖之4 小时前
基于ROS2,撰写python脚本,根据给定的舵-桨动力学模型实现动力学更新
开发语言·python·机器人·ros2
豆沙沙包?4 小时前
2025年- H77-Lc185--45.跳跃游戏II(贪心)--Java版
java·开发语言·游戏
军训猫猫头4 小时前
96.如何使用C#实现串口发送? C#例子
开发语言·c#
liuyang-neu5 小时前
java内存模型JMM
java·开发语言
利刃大大5 小时前
【在线五子棋对战】二、websocket && 服务器搭建
服务器·c++·websocket·网络协议·项目
喜欢吃燃面5 小时前
C++刷题:日期模拟(1)
c++·学习·算法