跳到正文

闲话

某人做题目做出来的动画片

BSOD_Winter约 3 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 3 分钟

版本

  1. v1当前

谁能猜到原题

玩法: 输入10*10的地图,其中含有’C’ ”F’两个单词……

C
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
char a[15][15];
int fx,fy,cx,cy;
int t=0;
int ff=1,fc=1;

void S(int x,int y){
    COORD pos;
    pos.X=y-1,pos.Y=x-1;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}

void F(){
	if(ff==1){
		if(a[fx-1][fy]=='*'||fx-1==0)ff++;
		else fx--;
		return;
	}
	if(ff==2){
		if(a[fx][fy+1]=='*'||fy+1==11)ff++;
		else fy++;
		return;
	}
	if(ff==3){
		if(a[fx+1][fy]=='*'||fx+1==11)ff++;
		else fx++;
		return;
	}
	if(ff==4){
		if(a[fx][fy-1]=='*'||fy-1==0)ff=1;
		else fy--;
		return;
	}
}
void C(){
	if(fc==1){
		if(a[cx-1][cy]=='*'||cx-1==0)fc++;
		else cx--;
		return;
	}
	if(fc==2){
		if(a[cx][cy+1]=='*'||cy+1==11)fc++;
		else cy++;
		return;
	}
	if(fc==3){
		if(a[cx+1][cy]=='*'||cx+1==11)fc++;
		else cx++;
		return;
	}
	if(fc==4){
		if(a[cx][cy-1]=='*'||cy-1==0)fc=1;
		else cy--;
		return;
	}
}
int main(){
	for(int i=1;i<=10;i++){
		for(int j=1;j<=10;j++){
			cin>>a[i][j];
			if(a[i][j]=='C'){
				cx=i;
				cy=j;
			}
			if(a[i][j]=='F'){
				fx=i;
				fy=j;
			}
		}
	}
	int ans=0;
	ff=1;
	fc=1;
	ans=10;
	while(1){
		Sleep(ans);
		S(30,10);
		cout<<t<<"                ";
		S(fx,fy);
		cout<<a[fx][fy];
		S(cx,cy);
		cout<<a[cx][cy];
		//cout<<fx<<"."<<fy<<"  "<<cx<<"."<<cy<<endl;
		t++;
		F();
		C();

		S(fx,fy);
		cout<<"F";
		S(cx,cy);
		cout<<"C";

		if(fx==cx&&fy==cy){
			cout<<t;
			return 0;
		}

	}
	return 0;
}
原文