背景
大家好鸭!不知道大家熟不熟悉这张图片呢?

没错!这就是系统里的cmd程序!
不过我倒是觉得它只能用来管理后台太枯燥了,于是,我自己原创了一个仿cmd的小游戏!
简单介绍
我的仿cmd小游戏里即可以进入真正的cmd后台,也能进入我编的程序。更多的话就自己体验一下吧!
代码部分
#include<iostream>
#include<bits/stdc++.h>
#include<ctime>
#include<conio.h>
#include<Windows.h>
#include<stdlib.h>
using namespace std;
int main()
{
cout<<"请输入密码:"<<endl;
int mima;
cin>>mima;
if(mima!=123698745)
{
Sleep(5000);
cout<<"运行时间较长,请耐心等待反馈错误信息........."<<endl;
Sleep(2000);
system("pause");
system("pause");
system("pause");
return 0;
}
cout<<"请选择你的身份:"<<endl;
int sf;
cout<<"1.管理员 2.游客"<<endl;
cin>>sf;
bool flag=false;
if(sf==1)
{
cout<<"请输入您的名字、密码:"<<endl;
char name;
int mm;
cin>>name>>mm;
if(name=='H'&&mm==123123)
{
flag=true;
system("cls");
cout<<"Welcome!"<<endl;
Sleep(2000);
cout<<"在主程序中(非真正cmd)输入999可获得惊喜。"<<endl;
Sleep(2000);
system("cls");
system("cmd");
}
else if(name=='m'&&mm==123698745)
{
flag=true;
system("cls");
cout<<"Welcome!"<<endl;
Sleep(2000);
cout<<"在主程序中(非真正cmd)输入999可获得惊喜。"<<endl;
Sleep(2000);
system("cls");
system("cmd");
}
else
{
cout<<"错误!!您即将以游客身份进入。"<<endl;
Sleep(2000);
}
}
unsigned long long cz=0;
system("cls");
cout<<"作者衷心的提醒您,不要输入字符、字符串指令或过长的数字";
for(int i=1;i<=25;i++)
{
cout<<".";
Sleep(100);
}
cout<<endl;
while(1)
{
system("color 0F");
system("cls");
cout<<endl;
cout<<"----------cmd----------"<<endl;
cout<<"1.计算器"<<endl;
cout<<"2.关机程序"<<endl;
cout<<"3.草稿纸"<<endl;
cout<<"4.系统查询"<<endl;
cout<<"5.cmd后台"<<endl;
cout<<"6.帮助"<<endl;
cout<<"7.仿黑客"<<endl;
cout<<"8.游戏"<<endl;
cout<<"9.画图"<<endl;
cout<<"10.放大镜"<<endl;
cout<<"输入-1退出程序。"<<endl;
cout<<"----请输入序号进行操作:";
cin>>cz;
if(cz==-1)return 0;
if(cz==1)
{
system("cls");
cout<<"请问您需要系统计算机(1)还是简单计算机(2)?"<<endl;
int xz;
cout<<"请输入:";
cin>>xz;
if(xz==1)
{
system("calc");
}
else if(xz==2)
{
system("cls");
cout<<"-----简易计算机-----"<<endl;
int a,b;
while(1)
{
cout<<"请输入两个数(整数)(-1退出):";
cin>>a;
if(a==-1)break;
cin>>b;
cout<<endl;
cout<<"和:"<<a+b<<endl;
cout<<"差:"<<a-b<<endl;
cout<<"积:"<<a*b<<endl;
cout<<"商:"<<a/b<<endl;
cout<<"余:"<<a%b<<endl;
system("pause");
system("cls");
}
}
}
else if(cz==2)
{
char ch;
system("cls");
cout<<"你需要知道取消关机密码方可安全关机!!"<<endl;\
Sleep(1000);
cout<<"继续输入y,取消输入n"<<endl;
cin>>ch;
if(ch=='y')
{
system("shutdown -s -t 120");
for(int i=3;i>=1;i--)
{
int qx;
cout<<"若要取消关机输入密码,否则输入-1(你还有"<<i<<"次机会)"<<endl;
cin>>qx;
if(qx==-1)break;
else if(qx==123698745)
{
system("shutdown -a");
break;
}
else cout<<"错误!"<<endl;
}
}
else continue;
}
else if(cz==3)
{
system("notepad");
}
else if(cz==4)
{
system("ver");
system("pause");
}
else if(cz==5)
{
system("cls");
system("cmd");
}
else if(cz==6)
{
cout<<"以下是cmd后台的指令:"<<endl;
system("pause");
system("help");
system("pause");
}
else if(cz==7)
{
system("cls");
cout<<"输入时间(建议100以上,否则太短):"<<endl;
int time;
cin>>time;
if(time%2==0)system("color 0a");
else system("color 0c");
for(int i=0;i<=time;i++)
{
cout<<"01001010010001011110101110101010001111110101";
}
system("pause");
system("color 0F");
}
else if(cz==8)
{
system("cls");
cout<<"请选择游戏:"<<endl;
int game;
cout<<"1.石头剪刀布 2.迷宫 3.问答小游戏"<<endl;
cin>>game;
if(game==1)
{
srand(time(0));
int sjb=0;
while(1)
{
system("cls");
cout<<"计算机已经想好了它要出的种类。"<<endl;
Sleep(1000);
cout<<"现在你来选择:1.石头 2.剪刀 3.布(-1退出)"<<endl;
cin>>sjb;
if(sjb==-1)break;
int cmt=rand()%3+1;
if(sjb==1)
{
switch(cmt)
{
case 1:cout<<"平局!计算机出"<<cmt<<endl,system("pause");break;
case 2:cout<<"你赢了!计算机出"<<cmt<<endl,system("pause");break;
case 3:cout<<"你输了!计算机出"<<cmt<<endl,system("pause");break;
}
}
if(sjb==2)
{
switch(cmt)
{
case 2:cout<<"平局!计算机出"<<cmt<<endl,system("pause");break;
case 3:cout<<"你赢了!计算机出"<<cmt<<endl,system("pause");break;
case 1:cout<<"你输了!计算机出"<<cmt<<endl,system("pause");break;
}
}
if(sjb==3)
{
switch(cmt)
{
case 3:cout<<"平局!计算机出"<<cmt<<endl,system("pause");break;
case 1:cout<<"你赢了!计算机出"<<cmt<<endl,system("pause");break;
case 2:cout<<"你输了!计算机出"<<cmt<<endl,system("pause");break;
}
}
}
}
else if(game==2)
{
char map[15][15]={{'-','-','-','-','-','-','-','-','-','-'},
{'|','0',' ',' ',' ','#',' ','#','#','|'},
{'|',' ',' ','#',' ','#',' ','#',' ','|'},
{'|','#',' ','#',' ',' ',' ',' ','#','|'},
{'|',' ',' ','#',' ','#',' ','#','#','|'},
{'|','#','#',' ','#',' ',' ',' ','#','|'},
{'|',' ','#',' ',' ',' ','#','#',' ','|'},
{'|',' ',' ',' ','#','#','#','#','#','|'},
{'|','#',' ','#',' ',' ',' ','#','#','|'},
{'|','#',' ',' ',' ','#',' ',' ','E','|'},
{'-','-','-','-','-','-','-','-','-','-'}};
char ch,st;
int sx,sy,ex,ey;
sx=1,sy=1,ex=9,ey=8;
system("cls");
cout<<"欢迎来到迷宫游戏!!"<<endl;
Sleep(1000);
cout<<"wasd分别是上左下右"<<endl;
Sleep(1000);
cout<<"输入y开始,n取消"<<endl;
cin>>st;
if(st!='y')continue;
system("cls");
cout<<"0是你,E是终点,空格是路,#是墙壁,-/|是边界"<<endl;
for(int i=0;i<11;i++)
{
for(int j=0;j<=10;j++)
{
cout<<map[i][j];
}
cout<<endl;
}
while(1)
{
ch=getch();
if(ch=='w')
{
if(map[sx-1][sy]!='-'&&map[sx-1][sy]!='#')
map[sx][sy]=' ',map[--sx][sy]='0';
}
else if(ch=='s')
{
if(map[sx+1][sy]!='-'&&map[sx+1][sy]!='#')
map[sx][sy]=' ',map[++sx][sy]='0';
}
else if(ch=='a')
{
if(map[sx][sy-1]!='|'&&map[sx][sy-1]!='#')
map[sx][sy]=' ',map[sx][--sy]='0';
}
else if(ch=='d')
{
if(map[sx][sy+1]!='|'&&map[sx][sy+1]!='#')
map[sx][sy]=' ',map[sx][++sy]='0';
}
if(sx==ex&&sy==ey)break;
system("cls");
cout<<"0是你,E是终点,空格是路,#是墙壁,-/|是边界"<<endl;
for(int i=0;i<11;i++)
{
for(int j=0;j<=10;j++)
{
cout<<map[i][j];
}
cout<<endl;
}
}
system("cls");
system("color 6E");
cout<<"你赢了!!!"<<endl;
system("pause");
system("color 0F");
}
else if(game==3)
{
system("cls");
cout<<"问答小游戏"<<endl;
system("pause");
if(MessageBox(NULL,("要继续吗?"),("问答小游戏"),MB_YESNO)==IDNO)return 0;
MessageBox(NULL,("好的!"),("问答小游戏"),MB_OK);
while(MessageBox(NULL,("1+1=2"),("问题1"),MB_ICONQUESTION|MB_YESNO)!=IDYES)
{
if(MessageBox(NULL,("你确定吗?"),("问题1"),MB_ICONINFORMATION|MB_RETRYCANCEL)==IDRETRY)continue;
else
{
MessageBox(NULL,("错误!"),("游戏结束"),MB_ICONSTOP|MB_OK);
return 0;
}
}
MessageBox(NULL,("答对了!"),("恭喜"),MB_OK);
while(MessageBox(NULL,("BDFS是指广搜"),("问题2"),MB_ICONQUESTION|MB_YESNO)!=IDNO)
{
if(MessageBox(NULL,("你确定吗?"),("问题2"),MB_ICONINFORMATION|MB_RETRYCANCEL)==IDRETRY)continue;
else
{
MessageBox(NULL,("错误!"),("游戏结束"),MB_ICONSTOP|MB_OK);
return 0;
}
}
MessageBox(NULL,("你真厉害"),("恭喜"),MB_OK);
MessageBox(NULL,("关卡题"),("警告"),MB_ICONEXCLAMATION|MB_OK);
while(MessageBox(NULL,("你是个蒟蒻"),("问题3"),MB_ICONQUESTION|MB_YESNO)!=IDYES)
{
if(MessageBox(NULL,("你确定吗?"),("问题3"),MB_ICONINFORMATION|MB_RETRYCANCEL)==IDRETRY)continue;
else
{
MessageBox(NULL,("恭喜大神成功跳关!"),("游戏结束"),MB_OK);
return 0;
}
}
MessageBox(NULL,("游戏结束后我会嘲讽并踩爆你"),("嘿嘿嘿"),MB_OK);
if(MessageBox(NULL,("要关机吗"),("问题4"),MB_ICONQUESTION|MB_YESNOCANCEL)==IDYES)
{
if(MessageBox(NULL,("你确定吗?"),("问题4"),MB_ICONINFORMATION|MB_YESNO)==IDYES)
{
MessageBox(NULL,("好的!"),("要关机了"),MB_OK);
system("shutdown -s -t 120");
return 0;
}
else MessageBox(NULL,("好的!"),("不关机了"),MB_OK);
}
else if(MessageBox(NULL,("要关机吗"),("问题4"),MB_ICONQUESTION|MB_YESNOCANCEL)==IDNO)
{
if(MessageBox(NULL,("你确定吗?"),("问题4"),MB_ICONINFORMATION|MB_YESNO)==IDYES)
{
MessageBox(NULL,("好的!"),("不关机了"),MB_OK);
}
else if(MessageBox(NULL,("是关还是不关?"),("???"),MB_ICONINFORMATION|MB_YESNO)==IDNO)
MessageBox(NULL,("好的!"),("不关机了"),MB_OK);
else
{
MessageBox(NULL,("好的!"),("要关机了"),MB_OK);
system("shutdown -s -t 120");
return 0;
}
}
MessageBox(NULL,("boss题"),("警告"),MB_ICONEXCLAMATION|MB_OK);
while(MessageBox(NULL,("ikun会打篮球"),("ikun"),MB_ICONQUESTION|MB_YESNO)!=IDYES)
{
if(MessageBox(NULL,("你确定吗?"),("ikun"),MB_ICONINFORMATION|MB_YESNO)==IDYES)
{
MessageBox(NULL,("错误!"),("ikun"),MB_ICONSTOP|MB_OK);
for(int i=1;i<=10;i++)
{
MessageBox(NULL,("鸡你太美"),("ikun"),MB_ICONEXCLAMATION|MB_OK);
}
return 0;
}
}
MessageBox(NULL,("over"),("over"),MB_OK);
}
}
else if(cz==9)
{
system("mspaint");
}
else if(cz==10)
{
system("magnify");
}
else if(cz==999&&flag)
{
system("cls");
for(int i=1;i<=130;i++)
{
cout<<(char)(i);
Sleep(150);
}
cout<<endl;
system("pause");
}
else cout<<"该指令不存在!!"<<endl,system("pause");
}
}
后记
只有短短400多行,也不多。另外,在这里告知大家,取消关机密码是123698745!千万记得!要不然关机了就完啦!哈哈
点个赞吧!