跳到正文

休闲·娱乐

口袋奇兵

_CMZ_Lychee_约 5 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年4月29日
篇幅
约 5 分钟

版本

  1. v1当前

有一点小像,但更草率,C++上面运行这串代码即可,ad左右移动,看看你的最后分数是多少

这个作品真的很想上全站推荐,可惜……

C++
#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
char a[213][6];
void writemap(){
	for(int i=0;i<=1;i++){
		for(int j=0;j<6;j++){
			a[i][j]='.';
		}
	}
	for(int i=0;i<6;i++)a[0][i]='!';
	for(int i=3;i<210;i++){
		if(i%6==0){
		    int t=rand()%4+1;
		    a[i][0]='|';
		    a[i][5]='|';
		    if(t==1){
		        a[i][1]='+';
		    }
		    if(t==2){
		    	a[i][1]='-';
            }
            if(t==3){
            	a[i][1]='*';
			}
			if(t==4){
				a[i][1]='/';
			}
			a[i][2]='0';a[i][2]+=rand()%9+1;
			int d=rand()%4+1;
		    if(d==1){
		        a[i][3]='+';
		    }
		    if(d==2){
		    	a[i][3]='-';
            }
            if(d==3){
            	a[i][3]='*';
			}
			if(d==4){
				a[i][3]='/';
			}
			a[i][4]='0';a[i][4]+=rand()%9+1;
	    }else{
	    	for(int j=0;j<6;j++)a[i][j]='.';
		}
	}
	for(int i=210;i<=212;i++){
		for(int j=0;j<=6;j++){
			a[i][j]='.';
		}
	}
}
bool canmove(int y){
	if(y<1||y>=5)return 0;
	return 1;
}
int main(){
	srand(time(NULL));
	string s="startgame";
	while(s=="startgame"){
		int x=210,y=3;
		cout<<"startgame/exit"<<endl;
	    cin>>s;
		system("cls");
	    if(s!="startgame")break;
	    writemap();
	    long long int Score=0;
	    int f=0;
	    while(a[x][y]!='!'){
	    	Sleep(10);
	    	system("cls");
	    	f++;
	    	for(int i=x-4;i<=x+1;i++){
	    		for(int j=0;j<6;j++){
	    			if(i!=x||j!=y)cout<<a[i][j];
	    			else cout<<'^';
				}
				cout<<endl;
			}
			cout<<"Score:"<<Score<<endl;
			if(_kbhit()){
				int k=_getch();
				switch(k){
					case 'a':
						if(canmove(y-1))y--;
					    break;
				    case 'd':
					    if(canmove(y+1))y++;
				    	break;
			    }
		    }

			if(f==15){
			    x--;
			    f=0;
				if(a[x][y]>='0'&&a[x][y]<='9'){
		            if(a[x][y-1]=='+')Score+=a[x][y]-'0';
		    	    if(a[x][y-1]=='-')Score-=a[x][y]-'0';
		    	    if(a[x][y-1]=='*')Score*=a[x][y]-'0';
		    	    if(a[x][y-1]=='/')Score/=a[x][y]-'0';
			    }
			    if(a[x][y]=='+'||a[x][y]=='-'||a[x][y]=='*'||a[x][y]=='/'){
		    	    if(a[x][y]=='+')Score+=a[x][y+1]-'0';
		    		if(a[x][y]=='-')Score-=a[x][y+1]-'0';
		    		if(a[x][y]=='*')Score*=a[x][y+1]-'0';
		    		if(a[x][y]=='/')Score/=a[x][y+1]-'0';
				}
			}
		}
		cout<<"Your Score:"<<Score<<endl;
	}
	return 0;
}

如果你感兴趣的话可以看看我的其他作品

扫雷

乒乓球游戏

贪吃蛇

逃离后室游戏

不要脸地要个小赞

原文