c puzzle

已取消 已发布的 Oct 21, 2008 货到付款
已取消 货到付款

Common puzzle with a 4x4 playing space with 15 tiles, numbered 1 through 15. One "spot" is always left blank.

The goal is to get the tiles in order, 1 through 15, from left to right, top to bottom, by just sliding tiles into the empty square. In this configuration, the goal would be to get the 14 and 15 to switch places, without affecting any of the other squares.

Your goal will be to write a program that allows the user to play this game.

The first part of your program will read in possible puzzle configurations from a file and choose one of them randomly. The file format is as follows:

The first line of the input file will contain a single positive integer n, representing the number of puzzles in the file. The puzzles will be contained in the next 5n lines. In particular, each puzzle will be stored in 5 lines. The first line will contain the first row of values in the puzzle separated by spaces. The second line will contain the second row, the third line, the third row and the fourth line, the fourth row. The blank spot will be designated by the integer 0. The last line (fifth) will be a blank line.

3

1 0 2 3

5 6 7 4

9 10 11 8

13 14 15 12

15 1 2 3

14 13 12 11

10 9 8 7

6 0 5 4

Output Specification

At the very beginning of the program, you will prompt the user to enter in the name of the file (this has already been done for you). Then, the program will open the file and load a puzzle into its memory. (You will do this in the loadPuzzle function.)

Once this is done, the puzzle should be displayed to the user (printPuzzle will do the work, but the call to this function is already in main) and the user should choose a tile to move. Roughly the board should print out as follows:

1 2 _ 3

5 6 7 4

9 10 11 8

13 14 15 12

Note that an underscore is to be used to denote the blank square and that internally, this is stored as 0.

Prompt the user with the following question after showing them the board:

Which piece would you like to slide into the open slot?

Note, answering 0 means you quit the game without winning.

If the user chooses a valid square, process the move and print out:

Sorry, that is not a valid square to slide into the open slot. No move has been executed.

If the user chooses 0, print out:

Sorry, looks like you gave up on the puzzle.

工程 MySQL PHP 项目管理 软件构架 软件测试

项目ID: #3326899

关于项目

19个方案 远程项目 活跃的Oct 23, 2008

有19名威客正在参与此工作的竞标,均价$37/小时

marchent

See private message.

$85 USD 在14天内
(168条评论)
6.3
bitdonkey

See private message.

$169.15 USD 在14天内
(111条评论)
6.1
genergabasa

See private message.

$85 USD 在14天内
(34条评论)
5.9
magadhmindslx

See private message.

$29.75 USD 在14天内
(166条评论)
5.4
winexsoft

See private message.

$12.75 USD 在14天内
(33条评论)
5.0
dimic

See private message.

$34 USD 在14天内
(14条评论)
4.4
Apogeesolutions

See private message.

$42.5 USD 在14天内
(67条评论)
4.5
vw6959454vw

See private message.

$21.25 USD 在14天内
(48条评论)
4.4
drboom

See private message.

$16.15 USD 在14天内
(27条评论)
4.2
pgmexpert

See private message.

$3.4 USD 在14天内
(5条评论)
2.6
vw6807901vw

See private message.

$17 USD 在14天内
(2条评论)
2.2
starscout

See private message.

$17 USD 在14天内
(0条评论)
0.0
vw7056055vw

See private message.

$8.5 USD 在14天内
(3条评论)
0.0
aselaben

See private message.

$27.2 USD 在14天内
(0条评论)
0.0
levgvw

See private message.

$25.5 USD 在14天内
(0条评论)
0.0
codeguru2008

See private message.

$42.5 USD 在14天内
(1条评论)
0.0
wickedtoad

See private message.

$42.5 USD 在14天内
(0条评论)
0.0
jimmysprogram

See private message.

$4.25 USD 在14天内
(0条评论)
0.0
tbteam

See private message.

$25.5 USD 在14天内
(0条评论)
0.0