求问
  • 板块灌水区
  • 楼主Silver_winter
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/1/4 16:37
  • 上次更新2025/1/4 16:50:04
查看原帖
求问
1125069
Silver_winter楼主2025/1/4 16:37

字符串数组定义没问题,可是输出却莫名有问题,求解答

#include<bits/stdc++.h>
#include<windows.h>
#include <conio.h>
using namespace std;
void S(int x,int y)
{
    COORD pos;
    pos.X=y*2+1,pos.Y=x+1;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
string map[7]={
	{"###########"},
	{"#         #"},
	{"#         #"},
	{"#         #"}, 
	{"#         #"}, 
	{"#         #"}, 
	{"###########"}
};
int bou=0;
bool bou2;
int x=5,y=1;
char role;
char f;
int main(){
	cout<<"角色名称(字符):";
	cin>>role;
	system("cls");
	for(int i=0;i<7;i++){
		cout<<map[i];//这里运行错误
		cout<<endl;
	}
	while(1){
		f=getch();
		if(f=='w'&&bou==0){
			bou2=1;
		}
		if(f=='a'&&map[x][y-1]==' '){
			S(x,y);
			cout<<" ";
			S(x,y+1);
			cout<<role;
		}
	}
	
	return 0;
}
2025/1/4 16:37
加载中...