为什么下面这段C++代码跑不了
  • 板块学术版
  • 楼主wza_whitenight
  • 当前回复1
  • 已保存回复1
  • 发布时间2021/6/15 13:54
  • 上次更新2023/11/4 21:51:53
查看原帖
为什么下面这段C++代码跑不了
170480
wza_whitenight楼主2021/6/15 13:54
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
const int N=100,M=100;
int n,m;
bool map[N][M]; 
class map
{
	private:
		bool **p;
		int n,m;
		inline bool isin(const int x1,const int y1,const int x2,const int y2,const int i,const int j)
		{
			return (((i>=((x1>x2)?x2:x1))&&(i<=((x1>x2)?x1:x2)))&&((j>=((y1>y2)?y2:y1))&&(j<=((y1>y2)?y1:y2))));
		}
		struct point
		{
			static int tar_x,tar_y;
			int x,y,b_dis;
			int f_dis()
			{
				return abs(x-tar_x)+abs(y-tar_y);
			}
			bool operator<(point b)
			{
				return (b_dis+f_dis())>(b.b_dis+b.f_dis());
			}
		};
	public:
		map(const int N,const int M)
		{
			n=N;
			m=M;
			p=new bool*[N+1];
			for(int i=1;i<=N;i++)
				p[i]=new bool[M+1];
		}
		~map()
		{
			for(int i=1;i<=n;i++)
				delete[] p[i];
			delete[] p;
		}
		void set_obstruction(const int x,const int y)
		{
			p[x][y]=true;
			return;
		}
		void set_obstruction(const int x1,const int y1,const int x2,const int y2)
		{
			for(int i=1;i<=n;i++)
				for(int j=1;j<=m;j++)
					if(isin(x1,y1,x2,y2,i,j))
						p[i][j]=true;
			return;
		}
		int get_way(const int x1,const int y1,const int x2,const int y2)
		{
			priority_queue<point> q;
			point::tar_x=x2;
			point::tar_y=y2;
			point start;
			start.x=x1;
			start.y=y1;
			q.push(start);
		}
};
int main()
{
	
	return 0;
}
//我想写一个A*寻路实现,但是这段BFS的优先队列似乎因为结构体的重载运算符跑不了了(555~~),求大佬告知怎么改啊? 
2021/6/15 13:54
加载中...