qq_43006674 2020-06-03 13:06 采纳率: 0%
浏览 239

图片这里语法出错了还是什么 为何总是报括号前缺少分号呢?

#include<vector>
#include<string.h>
#include<sstream>
#include<map>
#include<windows.h>
#include"MyStack.h" 
#include"DrawUtil.h"
#include"mapdata.h"
#include <iostream.h>

#define SLEEP_MS 1000
using namespace std;
string fromIntToString(int a)
{
    string res;
    stringstream ss;
    ss << a;
    ss>> res;
    return res;
}
int sequence[4][2]=
{
    {0,-1},{1,0},{0,1},{-1,0}
};
int main(int argc, char *argv[])
{
    std::map<string,int*>hm;
    MyStack<int*>stack;
    int visited[MAP_SIZE][MAP_SIZE];
    memset(visited,0,MAP_SIZE*MAP_SIZE*sizeof(int));
    bool flag=true;
    int start[4]={0,0,0,0};
    stack.push(start);
    int endCol;
    int endRow;
    while(flag)
    {
        int* currentEdge=stack.pop();
        int tempTarget[2]={currentEdge[2],currentEdge[3]};
        if(visited[tempTarget[1]][tempTarget[0]]==1)
        {
            continue;
        }
        visited[tempTarget[1]][tempTarget[0]]=1;
        hm[fromIntToString(tempTarget[1])+":"+fromIntToString(tempTarget[0])]=
        new int[2]{currentEdge[1],currentEdge[0]};
        Sleep(SLEEP_MS);
         if(mapStatus[tempTarget[1]][tempTarget[0]]==2)
         {
            endCol=tempTarget[0];
            endRow=tempTarget[1];
            break;
        }
        int currCol=tempTarget[0];
        int currRow=tempTarget[1];
        for(int k=0;k<4;k++)
        {
            int* rc=sequence[k];
            int i=rc[1];
            int j=rc[0];
            if(currRow+i>=0&&currRow<MAP_SIZE&&currCol>=0&&currCol<MAP_SIZE&&mapStatus[currRow+i][currCol+j]!=0)
            {
                int* tempEdge=new int[4];
                tempEdge[0] = currCol;
                tempEdge[1] = currRow;
                tempEdge[2]=currCol+j;
                tempEdge[3]=currRow+i;
                stack.push(tempEdge);
            }
            drawMap(mapStatus,visited,true);
         }
         MyStack<string> pathStr;
         string currP=fromIntToString(endRow)+":"+fromIntToString(endCol);
         pathStr.push(currP);
         while(true)
         {
            int* tempP=hm[currP];
            currP=fromIntToString(tempP[0])+":"+fromIntToString(tempP[1]);
            if(mapStatus[tempP[0]][tempP[1]]==1)
            {
                mapStatus[tempP[0]][tempP[1]]=4;
             }
             pathStr.push(currP);
             if(tempP[0]==0&&tempP[1]==0)
             {
                break;
            }
        }
    cout<<"=========================================="<<endl;
    int count=0;
    while(!pathStr.isEmpty())
    {
        count++;
        cout<<pathStr.pop()<<"->";
        if(count==10);
        {
            count=0;
            cout<<endl; 
        }
    }
    cout<<"Finish"<<endl;
    cout<<"============================================"<<endl;
    drawMap(mapStatus,visited,false);
    return 0;
}}

图片说明图片说明

  • 写回答

1条回答 默认 最新

  • QiQaWgYu 2020-06-03 14:16
    关注

    typedef int arrT[2];
    hm[fromIntToString(tempTarget[1])+":"+fromIntToString(tempTarget[0])] = new arrT{currentEdge[1],currentEdge[0]};

    转自https://blog.csdn.net/itworld123/article/details/79811751

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器