积极答复者
求解,这是从老师那里拷过来的,在他的上面可以运行

问题
-
#include "stdafx.h"
struct node
{
int x;
int y;
};struct stack
{
int top;
node* elem;
int maxsize;
};void initstack(stack* s,int sz)
{
s->top=-1;
s->maxsize=sz;
s->elem=(node *)malloc(sz*sizeof(node));
}bool isempty(stack* s)
{
return s->top==-1? 1:0;
}void push(stack* s, node n)
{s->elem[s->top+1]=n;
s->top++;
}node pop(stack* s)
{
s->top--;
return s->elem[s->top+1];
}node gettop(stack* s)
{
return s->elem[s->top];
}int main(int argc, char* argv[])
{
// printf("Hello World!\n");
int migong[10][10]=
{{1,1,1,1,1,1,1,1,1,1},
{1,0,0,1,0,0,0,1,0,1},
{1,0,0,1,0,0,0,1,0,1},
{1,0,0,0,0,1,1,0,0,1},
{1,0,1,1,1,0,0,0,1,1},
{1,0,0,0,1,0,0,0,1,1},
{1,0,1,0,0,0,1,0,0,1},
{1,1,1,1,1,0,1,1,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1},
};node begin,end;
begin.x=1;
begin.y=1;
end.x=8;
end.y=8;
stack* path;
path=(stack*)malloc(sizeof(stack));
initstack(path,100);
push(path,begin);
migong[begin.x][begin.y]=1;
int status=1;
while((gettop(path).x!=end.x ||gettop(path).y!=end.y) && !isempty(path))
{
node temp=gettop(path);
if(migong[temp.x][temp.y+1]==0)
{ node next;
next.x=temp.x;
next.y=temp.y+1;
push(path,next);
printf("push east node: %d,%d\n",next.x,next.y);
migong[next.x][next.y]=1;
status=0;
}
else if(migong[temp.x+1][temp.y]==0 && status==1)
{
node next;
next.x=temp.x+1;
next.y=temp.y;
push(path,next);
printf("push south node: %d,%d\n",next.x,next.y);
migong[next.x][next.y]=1;
status=0;
}
else if(migong[temp.x][temp.y-1]==0 && status==1)
{
node next;
next.x=temp.x;
next.y=temp.y-1;
push(path,next);
printf("push west node: %d,%d\n",next.x,next.y);
migong[next.x][next.y]=1;
status=0;
}
else if(migong[temp.x-1][temp.y]==0 && status==1)
{
node next;
next.x=temp.x-1;
next.y=temp.y;
push(path,next);
printf("push north node: %d,%d\n",next.x,next.y);
migong[next.x][next.y]=1;
status=0;
}
else
{
node prev;
prev=pop(path);
printf("pop node(turn back): %d,%d\n",prev.x,prev.y);
}
status=1;
}
return 0;
}为什么在vc6++上运行时出错c:\program files\microsoft visual studio\myprojects\02\02.cpp(4) : fatal error C1083: Cannot open precompiled header file: 'Debug/02.pch': No such file or directory
答案
-
rebuild,或者删除工程文件,重新编译。
麻烦把正确答案设为解答。- 已建议为答案 VisualElevenModerator 2011年3月28日 1:00
- 已标记为答案 lucy-liuModerator 2011年3月28日 10:52
-
这个问题的原因是因为预编译头文件不对
把你的debug和release目录删除,重新编译 或者 直接在工程属性里设置不使用预编译头文件
0xBAADF00D- 已建议为答案 VisualElevenModerator 2011年3月28日 1:01
- 已标记为答案 lucy-liuModerator 2011年3月28日 10:52
-
try Rebuild All
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.- 已建议为答案 VisualElevenModerator 2011年3月28日 1:01
- 已标记为答案 lucy-liuModerator 2011年3月28日 10:52
-
Hi tangwu,您好!像大家所说的这个错误时预编译文件的设置造成的。您可以尝试以下几种方法来解决:
1)单独编译StdAfx.cpp2)编译所有(即按Ctrl+F7)
3)在工程-设置-c++-最下面的工程选项里去掉02.pch文件
4)在工程-设置-c++-在分类里选择预编译头文件,选择自动使用预补偿页眉,或者选择不使用预补偿头
如果您的问题解决了,请把有用的回答标记为答案!谢谢,
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 VisualElevenModerator 2011年3月28日 1:01
- 已标记为答案 lucy-liuModerator 2011年3月28日 10:52
全部回复
-
rebuild,或者删除工程文件,重新编译。
麻烦把正确答案设为解答。- 已建议为答案 VisualElevenModerator 2011年3月28日 1:00
- 已标记为答案 lucy-liuModerator 2011年3月28日 10:52
-
这个问题的原因是因为预编译头文件不对
把你的debug和release目录删除,重新编译 或者 直接在工程属性里设置不使用预编译头文件
0xBAADF00D- 已建议为答案 VisualElevenModerator 2011年3月28日 1:01
- 已标记为答案 lucy-liuModerator 2011年3月28日 10:52
-
try Rebuild All
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.- 已建议为答案 VisualElevenModerator 2011年3月28日 1:01
- 已标记为答案 lucy-liuModerator 2011年3月28日 10:52
-
Hi tangwu,您好!像大家所说的这个错误时预编译文件的设置造成的。您可以尝试以下几种方法来解决:
1)单独编译StdAfx.cpp2)编译所有(即按Ctrl+F7)
3)在工程-设置-c++-最下面的工程选项里去掉02.pch文件
4)在工程-设置-c++-在分类里选择预编译头文件,选择自动使用预补偿页眉,或者选择不使用预补偿头
如果您的问题解决了,请把有用的回答标记为答案!谢谢,
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 VisualElevenModerator 2011年3月28日 1:01
- 已标记为答案 lucy-liuModerator 2011年3月28日 10:52