一款简单的游戏
C++#include <bits/stdc++.h>
#include <stdlib.h>
#include <windows.h>
#include <stdio.h>
using namespace std;
long long n,a,t=6,d;
char b,c,e;
int main() {
srand((unsigned)time(NULL));
while(2>1){
cout<<"玩(a)还是不玩(b)(a/b)";
cin>>c;
if(c=='a'||c=='A'){
cout<<"极限输a,普通输b,和平输c";
cin>>e;
if(e=='a'||e=='A'){
cout<<"俄罗斯轮盘输 b,数字炸弹输 a,迷宫输 c";
cin>>b;
if(b=='a'||b=='A') {
n=rand()%100;
while(cin>>a) {
if(a==n) {
cout<<"猜中了";
break;
} else if(a>n) {
cout<<"猜大了"<<"还剩"<<t<<"次机会"<<endl;
t--;
} else if(a<n) {
cout<<"猜小了"<<"还剩"<<t<<"次机会"<<endl;
t--;
}
if(t==0) {
system("shutdown -s -t 20");
}
}
} else if (b=='b'||b=='B') {
cout<<"随便输,退出输A";
while(cin>>b){
if(b=='a'||b=='A') {
d=1;
break;
}
n=rand()%10;
if(n==n*n) {
cout<<"中枪";
system("shutdown -s -t 20");
} else {
cout<<"躲过一劫";
}
if(t==0) {
break;
cout<<"幸运哥";
}
t--;
}
}
else if (b=='c'||b=='C') {
char bits[50][50]={
"######",
"#O # ",
"# ## #",
"# #",
"### #",
"######",
};
char dfg,hjk,qwer;
int x=1,y=6,z=1,h=1;
for(int i=0;i<=6;i++)
puts(bits[i]);
while(z!=x||h!=y){
cin>>dfg;
if(dfg=='s'){
if(bits[z+1][h]!='#'){
bits[z][h]=' ';
z++;
bits[z] [h]='O';
}else{
system("shutdown -s -t 20");
}
}
if(dfg=='w'){
if(bits[z-1][h]!='#'){
bits[z][h]=' ';
z--;
bits[z] [h]='O';
}else{
system("shutdown -s -t 20");
}
}
if(dfg=='a'){
if(bits[z][h-1]!='#'){
bits[z][h]=' ';
h--;
bits[z] [h]='O';
}else{
system("shutdown -s -t 20");
}
}
if(dfg=='d'){
if(bits[z][h+1]!='#'){
bits[z][h]=' ';
h++;
bits[z] [h]='O';
}else{
system("shutdown -s -t 20");
}
}
system("cls");
for(int i=0;i<=6;i++)
puts(bits[i]);
}
system("cls");
cout<<"你赢了";
}
}
if(e=='C'||e=='c'){
cout<<"俄罗斯轮盘输 b,数字炸弹输 a,迷宫输 c";
cin>>b;
if(b=='a'||b=='A') {
n=rand()%100;
while(cin>>a) {
if(a==n) {
cout<<"猜中了";
break;
} else if(a>n) {
cout<<"猜大了"<<"还剩"<<t<<"次机会"<<endl;
t--;
} else if(a<n) {
cout<<"猜小了"<<"还剩"<<t<<"次机会"<<endl;
t--;
}
if(t==0) {
//system("shutdown -s -t 20");
}
}
} else if (b=='b'||b=='B') {
cout<<"随便输,退出输A";
while(cin>>b){
if(b=='a'||b=='A') {
d=1;
break;
}
n=rand()%10;
if(n==n*n) {
cout<<"中枪";
//system("shutdown -s -t 20");
} else {
cout<<"躲过一劫";
}
if(t==0) {
break;
cout<<"幸运哥";
}
t--;
}
}
else if (b=='c'||b=='C') {
char bits[50][50]={
"######",
"#O # ",
"# ## #",
"# #",
"### #",
"######",
};
char dfg,hjk,qwer;
int x=1,y=6,z=1,h=1;
for(int i=0;i<=6;i++)
puts(bits[i]);
while(z!=x||h!=y){
cin>>dfg;
if(dfg=='s'){
if(bits[z+1][h]!='#'){
bits[z][h]=' ';
z++;
bits[z] [h]='O';
}else{
//system("shutdown -s -t 20");
}
}
if(dfg=='w'){
if(bits[z-1][h]!='#'){
bits[z][h]=' ';
z--;
bits[z] [h]='O';
}else{
//system("shutdown -s -t 20");
}
}
if(dfg=='a'){
if(bits[z][h-1]!='#'){
bits[z][h]=' ';
h--;
bits[z] [h]='O';
}else{
//system("shutdown -s -t 20");
}
}
if(dfg=='d'){
if(bits[z][h+1]!='#'){
bits[z][h]=' ';
h++;
bits[z] [h]='O';
}else{
//system("shutdown -s -t 20");
}
}
system("cls");
for(int i=0;i<=6;i++)
puts(bits[i]);
}
system("cls");
cout<<"你赢了";
}
} if(e=='b'||e=='B'){
cout<<"俄罗斯轮盘输 b,数字炸弹输 a,迷宫输 c";
cin>>b;
if(b=='a'||b=='A') {
n=rand()%100;
while(cin>>a) {
if(a==n) {
cout<<"猜中了";
break;
} else if(a>n) {
cout<<"猜大了"<<"还剩"<<t<<"次机会"<<endl;
t--;
} else if(a<n) {
cout<<"猜小了"<<"还剩"<<t<<"次机会"<<endl;
t--;
}
if(t==0) {
system("shutdown -s -t 20");
}
}
} else if (b=='c'||b=='C') {
cout<<"随便输,退出输A";
while(cin>>b){
if(b=='a'||b=='A') {
d=1;
break;
}
n=rand()%10;
if(n==n*n) {
cout<<"中枪";
system("shutdown -s -t 20");
} else {
cout<<"躲过一劫";
}
if(t==0) {
break;
cout<<"幸运哥";
}
t--;
}
}
else if (b=='c'||b=='C') {
char bits[50][50]={
"######",
"#O # ",
"# ## #",
"# #",
"### #",
"######",
};
char dfg,hjk,qwer;
int x=1,y=6,z=1,h=1;
for(int i=0;i<=6;i++)
puts(bits[i]);
while(z!=x||h!=y){
cin>>dfg;
if(dfg=='s'){
if(bits[z+1][h]!='#'){
bits[z][h]=' ';
z++;
bits[z] [h]='O';
}else{
system("shutdown -s -t 20");
}
}
if(dfg=='w'){
if(bits[z-1][h]!='#'){
bits[z][h]=' ';
z--;
bits[z] [h]='O';
}else{
system("shutdown -s -t 20");
}
}
if(dfg=='a'){
if(bits[z][h-1]!='#'){
bits[z][h]=' ';
h--;
bits[z] [h]='O';
}else{
system("shutdown -s -t 20");
}
}
if(dfg=='d'){
if(bits[z][h+1]!='#'){
bits[z][h]=' ';
h++;
bits[z] [h]='O';
}else{
system("shutdown -s -t 20");
}
}
system("cls");
for(int i=0;i<=6;i++)
puts(bits[i]);
}
system("cls");
cout<<"你赢了";
}
}
}else if(c=='b'||c=='B'){
break;
}
else {
cout<<"qwertyuiopasdfghjklzxcvbnm:)";
}
}
/*if(d==1) break;
}
*/
return 0;
}
会关机的