c语言 新手问题

[复制链接]
查看11 | 回复1 | 2008-9-5 03:31:21 | 显示全部楼层 |阅读模式
假如EXIT: 1 9

...b...c..

##.b...c..

..aaa.d...

geee..d.ff

g.....d...
代表一个停车场 .代表空位置 字母代表车##是我的车 现在要把车开出去 (你可以上下左右移动其他车) 如何写下面的简单方法?
/* isValidLocation(l) returns true iff l represents a location within
the bounds of the carpark.
*/
static bool isValidLocation(LOCATION l)
{
if location1==1;

return true;
}
/* isValidCarparkEntry(c) returns true iff c is a valid character that
can appear in a carpark-file.
*/
static bool isValidCarparkEntry(char c)
{
return true;
}
/* trimLine(line) removes any trailing new-line or carriage-return
characters from the end of line.
*/
static void trimLine(char line[])
{
}
/* getValue(l) returns the character representing the car segment
occupying location l in the carpark.The function terminates the program
if the location is not valid (i.e. outside the bounds of the carpark).
*/
static char getValue(LOCATION l)
{
return EMPTY;
}
十分感谢!!

回复

使用道具 举报

千问 | 2008-9-5 03:31:21 | 显示全部楼层
定义一个矩阵,0元表示空位,定义一个出口。 定一个一个结构体,包含 矩阵坐标 x y 和当前探测方向值d 用 1 2 3 4表示上下左右。 =================== 从你车位位置开始,一次以顺时针方向,先从左探测下一个车位是否为空,如果为空,则蒋当前方格信息的结构体进栈。如果下一个所有方向均被探测不能走,则,退栈一格,顺时针旋转90度,同时方向变量d+1。如果d=4且不可进一格,则蒋当前方格置为一格特殊值,表示不能再从此经过。继续退栈。可以设置一个辅助的脚印矩阵。 最后到达出口时栈中的元素即为路线。 ==================== 自己写吧。...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行