用C++写的,一共五个选项

#include <iostream>//包含输出输入的头文件 
#include<windows.h>//包含系统函数的头文件 
#include<time.h>   //包含时间函数的头文件 
#include<stdlib.h> //包含空间函数的头文件 
#include<conio.h>  //包含方位函数的头文件 
#include <cstdlib> //包含空间函数的头文件
#include <random>  //包含随机函数的头文件 
#include <ctime>   //包含时间函数的头文件
using namespace std;//命名空间 
int qiaozhuozi()   //定义函数qiaozhuozi 
{
	system("color 0c");//将文字颜色换成红色 
	int c;//定义变量c 
	printf("你想玩几次?请输入一个数:\n");//输出 "你想玩几次?请输入一个数:"并换行 
	cin >> c;//输入c 
	for(int d=0;d<c;d++)//for循环,定义d,d<输入的c,d自增 
	{//无 
		int a=0;//定义变量a,赋值为0 
		int b=0;//定义变量b,赋值为0 
		cout << "你想从几开始循环?请输入一个数:\n";//输出"你想从几开始循环?请输入一个数:"并换行 
		cin >> a;//输入a 
		cout << "你想从哪里结束循环?请输入一个数:\n";
		cin >> b;
		for(;a<=b;a++)
		{
			if(a%7==0||a/7==7||a/7==0||a/10==7||a%10==7||a%7==7)
			{
				cout << a << "敲桌子!!!" << endl;
			}
			else
			{
				cout << a << endl;
			}
		}
	}
	system("color F");
	return 34-34;
} 
int cppguanyushizhegeisrandcaishuyouxidefeichangfuzabiantaidechengxudequanbudaimaya()
{
		system("color 0c");
		srand((unsigned)time(0));
		int t;
		cout << "选择数值范围:" << endl;
		cin >> t; 
		long double a=rand()%t;
		printf("猜数游戏开始!!!请输入一个数(0~%d之间):\n",t);
		string c="小了!!!";
		string d="大了!!!";
		string e="恭喜你,猜对了!!!";
		for(int i=0;i<=2147483647;i++)
		{
			int b[i];
			cin >> b[i];
			if(b[i]>t)
			{
				cout << "error!" << endl;
			}
			if(b[i]<a)
			{
				cout << c << endl;
			}
			if(b[i]>a)
			{
				cout << d << endl;
			}
			if(b[i]==a)
			{
				cout << e << endl;
				system("color F");
				printf("共用%d次呦!!!\n",i);
				return 5-5;
			}
			if(b[i]==20140801)
			{
				system("color A");
				cout << "哇塞~你竟然输入了作者的生日!!!!!!!" << endl;
			}
		}
}
int jisuanqi()
{
	system("calc");
	return 0;
}
int shitoujiandaobu()
{
	system("color 0c");
	int n;
	int m;
	cout << "石头剪刀布游戏现在开始!" << endl;
	cout << "规则:" << endl;
	cout << "n先输,输完后用手捂住,然后m再输,输完后用手捂住,最后一起松开。" << endl;
	int c;
	cout << "你想玩几次?:" << endl;
	cin >> c;
	for(int d=0;d<c;d++)
	{
		cout << "1石头2剪刀3布" << endl;
		cin >> n;
		cin >> m;
		if(n!=1&&n!=2&&n!=3&&m!=1&&m!=2&&m!=3)
		{
			cout << "error!" << endl;
		}
		if (n==1&&m==1)
		cout << "平局"  << endl;
		else if (n==2&&m==2)
		cout << "平局"  << endl;
		else if (n==3&&m==3)
		cout << "平局"  << endl;
		else if (n==1&&m==2)
		cout << "n赢了" << endl;
		else if (n==2&&m==3)
		cout << "n赢了" << endl;
		else if (n==3&&m==1)
		cout << "n赢了" << endl;
		else if (n==2&&m==1)
		cout << "m赢了" << endl;
		else if (n==3&&m==2)
		cout << "m赢了" << endl;
		else if (n==1&&m==3)
		cout << "m赢了" << endl;
		else if(n==20140801||m==20140801)
		{
			system("color A");
			cout << "哇塞~你竟然输入了作者的生日!!!!!!!" << endl;
		}
		system("pause");
	}
	system("color F");
	cout << "游戏结束" << endl;
	return 0+0;
} 
int lunpandu()
{
	srand((unsigned)time(0));
	system("color 0c");
	cout << "规则:\n";
	cout << "假设有一把手枪,有六个弹孔,里面有一颗子弹。如果没有开枪,则获得1000000元,如果开抢则将元数清零。" << endl;
	int a=rand()%6;
	int c=0;
	int d=0;
		int b[c];
			cout << "请选择开枪单孔号码:" << endl;
			
			while(a!=0)
			{	while(c<6)
				{	
					cin >> b[c];	
								if(b[c]==a)
								{
									cout << "你失败了!" << endl;
									d=0;
									return 0;
								}
								if(b[c]>a||b[c]<a)
								{
									cout << "恭喜你奖金加1000000!!!" << endl;
									d+=1000000;
								}
								if(c==5)
								{
									cout << "恭喜你带回了5000000元!" << "游戏结束\n" << endl;
									return 0;
								}
					c++;
				} 
			
			}
		
	return 0;
} 
int caidan()
{
	system("color A");
	cout << "哇塞~你竟然输入了作者的生日!!!!!!!" << endl;
	int a;
		cout << "玩猜数的话写1,玩敲桌子的话写2,玩石头剪刀布的话写3,打开计算器的话写4,玩轮盘赌的话写5,不玩写0:" << endl;
		cin >> a;
		if(a!=1&&a!=0&&a!=2&&a!=3&&a!=4&&a!=5&&a!=20140801)
		{
			system("color 0c");
			cout << "error!" << endl;
			return 6-6;
		}
		else if(a==1)
		{
			cppguanyushizhegeisrandcaishuyouxidefeichangfuzabiantaidechengxudequanbudaimaya();
		}
		else if(a==2)
		{
			qiaozhuozi();
		}
		else if(a==3)
		{  
			shitoujiandaobu();
		}
		else if(a==4)
		{
			jisuanqi();
		} 
		else if(a==5)
		{
			lunpandu();
		}
		else if(a==20140801)
		{
			caidan();
		}
		else if(a==0)
		{
			system("color 0c");
			printf("结束\n");
			return 1234-1233;
		}
	return 9-9;
}
int main()
{
	int a;
	cout << "玩猜数的话写1,玩敲桌子的话写2,玩石头剪刀布的话写3,打开计算器的话写4,玩轮盘赌的话写5,不玩写0:" << endl;
	cin >> a;
	if(a!=1&&a!=0&&a!=2&&a!=3&&a!=4&&a!=5&&a!=20140801)
	{
		system("color 0c");
		cout << "error!" << endl;
		return 6-6;
	}
	else if(a==1)
	{
		cppguanyushizhegeisrandcaishuyouxidefeichangfuzabiantaidechengxudequanbudaimaya();
	}
	else if(a==2)
	{
		qiaozhuozi();
	}
	else if(a==3)
	{
		shitoujiandaobu();
	}
	else if(a==4)
	{
		jisuanqi();
	} 
	else if(a==5)
	{
		lunpandu();
	}
	else if(a==20140801)
	{
		caidan();
	}
	else if(a==0)
	{
		system("color 0c");
		printf("结束\n");
		return 1234-1233;
	}
	return 0;
}

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值