【2010NOIP】乌龟棋
  • 板块灌水区
  • 楼主Sy_Mclearn
  • 当前回复6
  • 已保存回复6
  • 发布时间2025/2/5 16:36
  • 上次更新2025/2/5 20:14:05
查看原帖
【2010NOIP】乌龟棋
947600
Sy_Mclearn楼主2025/2/5 16:36

自制小游戏【乌龟棋】。

#include<bits/stdc++.h>
#include<windows.h>
#include <cstdlib> 
#include <ctime> 
using namespace std;
int k[101],t[101],s=1;
int main(){
	puts("————————————————NOIP首创游戏之————————————————"); 
    puts("——————————乌——————————龟——————————棋——————————");
    Sleep(3000);
    system("cls");
    for(int i=1;i<=10;i++){
        cout<<"加载中";
        for(int j=1;j<=i;j++) cout<<"□";
        Sleep(200);
        system("cls");
    }
    cout<<"本游戏由Sy_Mclearn制作。"<<endl;
    puts(" ");
    cout<<"规则:"<<endl;
	puts("乌龟棋的棋盘是一行N个格子,每个格子上一个分数(非负整数)。");
	puts("棋盘第1格是唯一的起点,第N格是终点,游戏要求玩家控制一个乌龟棋子从起点出发走到终点。");
	puts("没有使用过的爬行卡片,控制乌龟棋子前进相应的格子数,每张卡片只能使用一次。");
	puts("游戏中,乌龟棋子自动获得起点格子的分数,并且在后续的爬行中每到达一个格子,就得到该格子相应的分数。");
	puts("玩家最终游戏得分就是乌龟棋子从起点到终点过程中到过的所有格子的分数总和。");
	system("pause");
	//puts("");
	//Sleep(200);
	//system("cls");
	system("cls");
    int m,n,cnt=0;
    puts("请输入棋盘长度与爬行卡片数。(小于100)");
    cin>>n>>m;
    system("cls");
    puts("以下是每一张爬行卡能爬行的距离:");
	srand((unsigned int )time(NULL));
	for(int i=1;i<=m;i++){
		k[i]=rand()%4+1;
		cout<<k[i]<<" ";
	}
	puts("");
	puts("");
	puts("");
	srand((unsigned int )time(NULL));
	puts("以下是每一个格子的分值:");
	for(int i=1;i<=n;i++){
		t[i]=rand()%(10000-1)+1;
		cout<<t[i]<<" ";
	}
	cnt=t[1];
	puts("");
	puts("");
	puts("");
	cout<<"您在第"<<s<<"格。"<<endl;
	cout<<"您目前有"<<cnt<<"分。"<<endl;
	puts("请输入您要使用的爬行卡的序号(从左到右依次对应1到m):(若结束游戏或无法移动则输入-1)"); 
	int x;
	while(cin>>x){
		system("cls");
		if(x==-1){
			cout<<"您失败了。";
			return 0; 
		}
		else if(x<1||k[x]+s>m){
			puts("请重新输入");
			Sleep(3000);
			system("cls");
			puts("");
			puts("");
			puts("");
			puts("以下是每一张爬行卡能爬行的距离:");
			for(int i=1;i<=m;i++){
				if(k[i]!=-1)
					cout<<k[i]<<" ";
				else
					cout<<"已用"<<" ";
			}
			puts("");
			puts("");
			puts("");
			puts("以下是每一个格子的分值:");
			for(int i=1;i<=n;i++){
				cout<<t[i]<<" ";
			}
			puts("");
			puts("");
			puts("");
			cout<<"您在第"<<s<<"格。"<<endl;
			cout<<"您目前有"<<cnt<<"分。"<<endl;
			puts("请输入您要使用的爬行卡的序号(从左到右依次对应1到m):(若结束游戏或无法移动则输入-1)"); 
		}
		else{
			s+=k[x];
			k[x]=-1;
			cnt+=t[s];
			if(s==n){
				puts("");
				puts("");
				puts("");
				cout<<"您已成功到达终点!!!"<<endl;
				cout<<"您共计获得了"<<cnt<<"分。"<<endl;
				return 0;
			}
			puts("");
			puts("");
			puts("");
			puts("以下是每一张爬行卡能爬行的距离:");
			for(int i=1;i<=m;i++){
				if(k[i]!=-1)
					cout<<k[i]<<" ";
				else
					cout<<"已用"<<" ";
			}
			puts("");
			puts("");
			puts("");
			puts("以下是每一个格子的分值:");
				for(int i=1;i<=n;i++){
				cout<<t[i]<<" ";
			}
			puts("");
			puts("");
			puts("");
			cout<<"您在第"<<s<<"格。"<<endl;
			cout<<"您目前有"<<cnt<<"分。"<<endl;
			puts("请输入您要使用的爬行卡的序号(从左到右依次对应1到m):(若结束游戏或无法移动则输入-1)"); 
		}
	}
	
    return 0;
}

欢迎大家提出建议。

2025/2/5 16:36
加载中...