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;
}

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

相关推荐
.小小陈.6 分钟前
Linux 多线程进阶:线程互斥、同步、线程池、死锁与线程安全、读写锁、自旋锁
linux·开发语言·c++
lingran__14 分钟前
C++入门基础
开发语言·c++
吃好睡好便好34 分钟前
Matlab中三种三维图的对比
开发语言·人工智能·学习·算法·matlab·信息可视化
代码改善世界43 分钟前
【C++进阶】二叉搜索树
java·数据结构·c++
Highcharts.js44 分钟前
无需搭建数据管道,如何快速上线投资基金筛选器?
开发语言·javascript·react.js·前端框架·highcharts
雨落在了我的手上44 分钟前
初识java(六):方法的使用
java·开发语言
春蕾夏荷_7282977251 小时前
c++ 编译abseil-cpp
c++·abseil-cpp
如竟没有火炬1 小时前
至少有K个重复字符的最长子串
开发语言·数据结构·python·算法·leetcode·动态规划
三品吉他手会点灯1 小时前
C语言学习笔记 - 32.嵌入式C语言学习阶段对初学编程者的建议
c语言·开发语言·笔记·学习
l1t1 小时前
DeepSeek总结的一种带宽高效的压缩基数排序FractalSortCPU
开发语言·python