输入文件:
2010-05-16 20:25:49 jiakai@JiaKai tmp 23 1020
$ cat manhattan.in
2 3
WE
NNS
3 9
1 4 2
2
1 3 2 1
2 3 2 2
编译参数:
g++ manhattan.cpp -o manhattan -g -Wall
软件版本:
2010-05-16 20:27:43 jiakai@JiaKai tmp 25 1022
$ g++ --version
g++ (GCC) 4.1.2
Copyright (C) 2006 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。
2010-05-16 20:28:23 jiakai@JiaKai tmp 26 1023
$ gdb --version
GNU gdb (GDB) 7.1
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
开始gdb:
2010-05-16 20:28:26 jiakai@JiaKai tmp 27 1024
$ gdb ./manhattan
GNU gdb (GDB) 7.1
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/manhattan...done.
(gdb) b 105
Breakpoint 1 at 0x8048894: file manhattan.cpp, line 105.
(gdb) r
Starting program: /tmp/manhattan
Breakpoint 1, Calculate (s=0) at manhattan.cpp:105
105 if (x1 == x2)
(gdb) s
110 if (y1 == y2)
(gdb)
112 else if (P(s, x1) == diry && P(s, x2) == diry)
(gdb)
113 AddDemand(y1, y2, dirx);
(gdb)
AddDemand (l=3, r=1, _dir=1) at manhattan.cpp:54
54 Cnt ++;
(gdb)
55 left[Cnt] = l, right[Cnt] = r, dir[Cnt] = _dir;
(gdb)
56 }
(gdb)
Calculate (s=0) at manhattan.cpp:112
112 else if (P(s, x1) == diry && P(s, x2) == diry)
(gdb)
113行执行完了,又回到了112.。。。 我表示目前无法解释。 记下来,以后慢慢研究。