Hello!又是美妙的一天,我给大家用c++做了一个小型网吧!希望大家喜欢,大家能不能点点赞呢?谢谢!
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<windows.h>
#include<bits/stdc++.h>
using namespace std;
void sb(){
CONSOLE_CURSOR_INFO cursor_info = { 1,0 };
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
void texiao(){
for(int i=1; i<=3; i++)
{
system("color 12&&color 23&&color 34&&color 45&&color 56&&color 67&&color 78");
}
system("color f2");
}
void dazi(string s){
for(int i=0;i<s.size();i++){
//TODO
cout<<s[i];
Sleep(30);
}
}
void cls(){
system("cls");
}
void jiazai(){
for(int j=1;j<=3;j++){
dazi("玩命加载中");
for(int i=1;i<=6;i++){
cout<<".";
}
}
}
void cs(){
cls();
int cnt=0,b;
string s="欢迎游玩猜数游戏!";
dazi(s);
texiao();
system("cls");
cout<<"\n";
s="请选择难度:";
cout<<" ";
dazi(s);
cout<<"\n";
cout<<" ";
s="1.数字范围:1~15 难度★";
dazi(s);
cout<<"\n";
cout<<" ";
s="2.数字范围:1~30 难度★★★";
dazi(s);
cout<<"\n";
cout<<" ";
s="3.数字范围:1~50 难度★★★★★";
dazi(s);
cout<<"\n";
cout<<" ";
s="4.数字范围:1~75 难度:王者";
dazi(s);
cout<<"\n";
cout<<" ";
s="5.数字范围:1~100 难度:半神";
dazi(s);
cout<<"\n";
cout<<" ";
s="6.数字范围:1~130 难度:神";
dazi(s);
cout<<"\n";
cout<<" ";
s="7.数字范围:1~150 难度:超神";
dazi(s);
cout<<"\n";
cout<<" ";
s="请选择:(输入序号)";
dazi(s);
int a,v;
cin>>a;
if(a==1){
cls();
jiazai();
srand(time(0));
v=rand()%15;
system("cls");
cout<<" ";
s="您有五次机会";
dazi(s);
cout<<"\n";
cout<<" ";
s="请输入:(1~15)";
dazi(s);
cout<<"\n";
while(cin>>b&&b!=v){
//TODO
if(cnt==4&&b!=v){
cout<<" 抱歉,您失败了!";
Sleep(1000);
cnt=0;
break;
}
if(b>v) cout<<" 大了!";
if(b<v){
//TODO
cout<<" 小了!";
}
cnt++;
}
cout<<" 恭喜猜中!";
texiao();
}
if(a==2){
jiazai();
srand(time(0));
v=rand()%30;
system("cls");
cout<<" ";
s="您有五次机会";
dazi(s);
cout<<"\n";
cout<<" ";
s="请输入:(1~30)";
dazi(s);
cout<<"\n";
while(cin>>b&&b!=v){
//TODO
if(cnt==4&&b!=v){
cout<<" 抱歉,您失败了!";
Sleep(1000);
cnt=0;
break;
}
if(b>v) cout<<" 大了!";
if(b<v){
//TODO
cout<<" 小了!";
}
cnt++;
}
cout<<" 恭喜猜中!";
texiao();
}
if(a==3){
jiazai();
srand(time(0));
v=rand()%50;
system("cls");
cout<<" ";
s="您有六次机会";
dazi(s);
cout<<"\n";
cout<<" ";
s="请输入:(1~50)";
dazi(s);
cout<<"\n";
while(cin>>b&&b!=v){
//TODO
if(cnt==5&&b!=v){
cout<<" 抱歉,您失败了!";
Sleep(1000);
cnt=0;
break;
}
if(b>v) cout<<" 大了!";
if(b<v){
//TODO
cout<<" 小了!";
}
cnt++;
}
cout<<" 恭喜猜中!";
texiao();
}
if(a==4){
jiazai();
srand(time(0));
v=rand()%75;
system("cls");
cout<<" ";
s="您有六次机会";
dazi(s);
cout<<"\n";
cout<<" ";
s="请输入:(1~75)";
dazi(s);
cout<<"\n";
while(cin>>b&&b!=v){
//TODO
if(cnt==5&&b!=v){
cout<<" 抱歉,您失败了!";
Sleep(1000);
cnt=0;
break;
}
if(b>v) cout<<" 大了!";
if(b<v){
//TODO
cout<<" 小了!";
}
cnt++;
}
cout<<" 恭喜猜中!";
texiao();
}
if(a==5){
jiazai();
srand(time(0));
v=rand()%100;
system("cls");
cout<<" ";
s="您有七次机会";
dazi(s);
cout<<"\n";
cout<<" ";
s="请输入:(1~100)";
dazi(s);
cout<<"\n";
while(cin>>b&&b!=v){
//TODO
if(cnt==6&&b!=v){
cout<<" 抱歉,您失败了!";
Sleep(1000);
cnt=0;
break;
}
if(b>v) cout<<" 大了!";
if(b<v){
//TODO
cout<<" 小了!";
}
cnt++;
}
cout<<" 恭喜猜中!";
texiao();
}
if(a==6){
jiazai();
srand(time(0));
v=rand()%130;
system("cls");
cout<<" ";
s="您有八次机会";
dazi(s);
cout<<"\n";
cout<<" ";
s="请输入:(1~130)";
dazi(s);
cout<<"\n";
while(cin>>b&&b!=v){
//TODO
if(cnt==7&&b!=v){
cout<<" 抱歉,您失败了!";
Sleep(1000);
cnt=0;
break;
}
if(b>v) cout<<" 大了!";
if(b<v){
//TODO
cout<<" 小了!";
}
cnt++;
}
cout<<" 恭喜猜中!";
texiao();
}
if(a==7){
jiazai();
srand(time(0));
v=rand()%150;
system("cls");
cout<<" ";
s="您有八次机会";
dazi(s);
cout<<"\n";
cout<<" ";
s="请输入:(1~150)";
dazi(s);
cout<<"\n";
while(cin>>b&&b!=v){
//TODO
if(cnt==7&&b!=v){
cout<<" 抱歉,您失败了!";
Sleep(1000);
cnt=0;
break;
}
if(b>v) cout<<" 大了!";
if(b<v){
//TODO
cout<<" 小了!";
}
cnt++;
}
cout<<" 恭喜猜中!";
texiao();
}
system("cls");
}
void db(){
dazi("欢迎来到赌场!");
Sleep(1000);
cls();
dazi("你要赌多少元");
string yuan;
cin>>yuan;
srand(time(0));
int dn;
dn=rand()%2+1;
if(dn==1){
cls();
dazi("你输了!唉唉唉!");
Sleep(1000);
}
else{
cls();
dazi("你赢了!");
texiao();
}
}
void jd(){
cls();
dazi("欢迎来到砸金蛋!");
Sleep(1000);
cls();
dazi("你要砸几号金蛋?\n");
dazi("1号金蛋 2号金蛋 3号金蛋 4号金蛋 5号金蛋 6号金蛋\n");
int zjd;
cin>>zjd;
srand(time(0));
int dn=rand()%6+1;
if(zjd==dn){
cls();
dazi("中奖了!");
texiao();
}
else{
cls();
dazi("没中!");
Sleep(1000);
}
}
int main(){
sb();
system("title 网吧&&color f2");
dazi("欢迎来到网吧!网吧将为您提供良好的游戏体验!");
Sleep(2000);
cls();
start:
sb();
cls();
cout<<" ";
dazi("您要玩什么?\n");
dazi("1.猜数游戏\n");
dazi("2.赌博(非不良引导)\n");
dazi("3.砸金蛋\n");
dazi("4.计算你所说的东西价值\n");
dazi("请选择:");
int xz;
cin>>xz;
switch (xz) {
sb();
case 1:
//TODO
cls();
cs();
break;
case 2:
//TODO
cls();
db();
break;
case 3:
cls();
jd();
break;
case 4:
cls();
dazi("暂未开放,敬请期待!");
Sleep(1000);
break;
}
goto start;
return 0;
}